Compile Imagemagick for Android using NDK

前端 未结 5 1695
离开以前
离开以前 2020-12-05 10:54

I\'m new in android, so i have a question to ask. I want to use the ImageMagick library to edit images in android but I don\'t wanna use the JMagick

相关标签:
5条回答
  • 2020-12-05 11:03

    You may choose opencv library instead!

    0 讨论(0)
  • 2020-12-05 11:04

    Just Ported it here, Still sketchy, But works for most.

    0 讨论(0)
  • 2020-12-05 11:10

    Use this one, it was compiled. it not awt; you just need compile test apk.Here is test example:

    public class TesteNdkActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            try {
                ImageInfo i = new ImageInfo("/sdcard/DCIM/Camera/IMG_20120226_230240.jpg");
                MagickImage m = new MagickImage(i);
    
                int newHeight = (int) ((640/(float)m.getWidth()) * m.getHeight());
                m = m.scaleImage(640, newHeight);
                m = m.cropImage(new Rectangle((640-480)/2, 0, 480, 480));
                m = m.charcoalImage(0.5, 0.5);
    
                try {
                    byte blob[] = m.imageToBlob(i);
                    FileOutputStream fos = new FileOutputStream(new File("/sdcard/foto_teste.jpg"));
                    fos.write(blob);
                    fos.close();
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            } 
            catch (MagickException e) {
                e.printStackTrace();
            }
        }
    }
    

    (text app will covert a picture to blob) I was successful, you will be successful. Enjoy it.

    0 讨论(0)
  • 2020-12-05 11:16

    I have ported it to android, and the code is in github.

    0 讨论(0)
  • 2020-12-05 11:20

    I guess nobody ported yet but you can do it yourself. You will basically need to get the sources and create an android.mk file.

    There are several links that helped me out to build another lib:

    • The Android.mk documentation.
    • This short tutorial.
    0 讨论(0)
提交回复
热议问题