简体   繁体   English

如何在Android中通过G4压缩将JPEG图像转换为TIFF格式?

[英]How to convert JPEG images to TIFF format with G4 compression in Android?

I am developing an android application and I want to be able to convert the camera pictures I take to tiff with Group 4 compression. 我正在开发一个android应用程序,我希望能够使用Group 4压缩将拍摄的相机图像转换为tiff。

I tried using this Android-ImageMagick library , but I get the following error: 我尝试使用此Android-ImageMagick库 ,但出现以下错误:

java.lang.UnsatisfiedLinkError - NDK java.lang.UnsatisfiedLinkError-NDK

I referred to this StackOverflow question to solve but it didn't work. 我提到了这个StackOverflow问题来解决,但没有成功。

Error occurs at the codes of library, Magick.java:43 line is the call of init(); 错误发生在库的代码上,Magick.java:43行是init()的调用; method. 方法。 Since we use of Gradle in Android Studio, I strongly doubt that it's because of Gradle. 由于我们在Android Studio中使用了Gradle,因此我强烈怀疑这是因为Gradle。 The explanation gave by the author of the library “how to use it” is based on project without Gradle. 库作者“如何使用它”的解释是基于没有Gradle的项目。 If we change the name of method “init()” to another name like “test()”, the error occurs at other native method. 如果我们将方法“ init()”的名称更改为“ test()”之类的其他名称,则在其他本机方法中会发生错误。 Our structure of project: 我们的项目结构:
and have added “ndk.dir” into local.properties, tried to add “sourceSets": 并将“ ndk.dir”添加到local.properties中,尝试添加“ sourceSets”:

{
        main {
            jni.srcDirs=['jniLibs']
        }
    }
    ” at build.gradle.

    /**
     * The sole purchase of this class is to cause the native
     * library to be loaded whenever a concrete class is used
     * and provide utility methods.
     *
     * @author Eric Yeo
     * @author Max Kollegov <virtual_max@geocities.com>
     */
    public class Magick {

        static {
            /*String clprop = System.getProperty("jmagick.systemclassloader");
            if (clprop == null || clprop.equalsIgnoreCase("yes")) {
                try {
                    ClassLoader.getSystemClassLoader()
                        .loadClass("magick.MagickLoader").newInstance();
                }
                catch(ClassN`enter code here`otFoundException e) {
                    throw new RuntimeException("Can't load MagickLoader " +
                                               "(class not found)");
                }
                catch(IllegalAccessException e) {
                    throw new RuntimeException("Access to SystemClassLoader "+
                                               "denied (IllegalAccessException)");
                }
                catch(InstantiationException e) {
                    throw new RuntimeException("Can't instantiate MagicLoader " +
                                               "(InstantiationException)");
                }
            }
            else {
                System.loadLibrary("JMagick");
            }*/

            System.loadLibrary("imagemagick");

            init();
        }


        /**
         * Initializes the ImageMagic system
         */
        private static native void init();


        /**
         * Parses a geometry specification and returns the
         * width, height, x, and y values in the rectangle.
         * It also returns flags that indicates which of the
         * four values (width, height, xoffset, yoffset) were
         * located in the string, and whether the x and y values
         * are negative.  In addition, there are flags to report
         * any meta characters (%, !, <, and >).
         * @param geometry String containing the geometry specifications
         * @param rect The rectangle of values x, y, width and height
         * @return bitmask indicating the values in the geometry string
         * @see magick.GeometryFlags
         */
        public static native int parseImageGeometry(String geometry, Rectangle rect);

    }

This is the error I get: 这是我得到的错误:

java.lang.UnsatisfiedLinkError: Native method not found: com.test.comp.magick.Magick.init:()V
            at com.test.comp.magick.Magick.init(Native Method)
            at com.test.comp.magick.Magick.<clinit>(Magick.java:43)
            at com.test.comp.magick.util.MagickBitmap.fromBitmap(MagickBitmap.java:41)
            at com.test.comp.activity.MainActivity.convertAndSendImage(MainActivity.java:60)
            at com.test.comp.activity.MainActivity.onActivityResult(MainActivity.java:84)
            at android.app.Activity.dispatchActivityResult(Activity.java:5423)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3347)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3394)
            at android.app.ActivityThread.access$1300(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

UnsatisfiedLinkError are thrown if ImageMagick library is not installed into your apk and causing linkage error: 如果ImageMagick库未安装到您的apk中,则会引发UnsatisfiedLinkError并导致链接错误:

Your library must be in directory /project/libs/armeabi/ 您的库必须位于目录/project/libs/armeabi/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM