title: using puelocesar / android-lib-magick
body: <p>I am  a beginner in Android. I want a sample app which uses this library: <a href="https://github.com/puelocesar/android-lib-magick" rel="nofollow noreferrer">https://github.com/puelocesar/android-lib-magick</a>. I tried to use <a href="https://github.com/lilac/Android-ImageMagick" rel="nofollow noreferrer">https://github.com/lilac/Android-ImageMagick</a> before - I made lots of changes to make it work but the result I got was not satisfactory.</p>
  
  <p>I just want to know which class to call for a particular thing.</p>
  
  <p>These are the effects i am getting using <a href="https://github.com/lilac/Android-ImageMagick" rel="nofollow noreferrer">https://github.com/lilac/Android-ImageMagick</a></p>
  
  <p><img src="https://i.stack.imgur.com/Wglka.png" alt="with no effect">
  <img src="https://i.stack.imgur.com/VQLrI.png" alt="Uniform Noise">
  <img src="https://i.stack.imgur.com/joV6n.png" alt="Poisson Noise">
  <img src="https://i.stack.imgur.com/Uaxnl.png" alt="Multiplicative Noise">
  <img src="https://i.stack.imgur.com/BHcZk.png" alt="Laplacian Noise">
  <img src="https://i.stack.imgur.com/zZxiZ.png" alt="Impulse Noise">
  <img src="https://i.stack.imgur.com/Legpk.png" alt="Gausian Noise">
  <img src="https://i.stack.imgur.com/0eAZ9.png" alt="Blur">
  <img src="https://i.stack.imgur.com/yC0fl.png" alt="Charcoal">
  <img src="https://i.stack.imgur.com/rZDMr.png" alt="Edge"></p>
  
  <p>blur, charcoal and no effect looks exactly same. when i select edge it shows blur image.
  and the noise effects appear but they look like red and green dots are drawn manually on that image.</p>
  
  <p>below is the code which runs application.</p>
  
  <p>it searches for images in sd card with hard coded name and extention. it gets all the ibages but i am unable to understand wha it does with those images because it shows only one image on screen.</p>
  
  <p>also dont know test.txt is created. this code is present in library as AndroidMagickActivity</p>
  
  <p>i did some changes in android.mk file after searching for long time and now its running but the output is not that good.</p>
  
  <p>please anybody help me to improve results of lilac library or help me to understand how to use <a href="https://github.com/puelocesar/android-lib-magick" rel="nofollow noreferrer">https://github.com/puelocesar/android-lib-magick</a></p>
  
  <p>i am beginner and i don't know how to use NDK and how to create JNI and .so files </p>
  
  <pre><code>package magick;
  
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  
  import android.app.Activity;
  import android.app.Dialog;
  import android.app.ProgressDialog;
  import android.graphics.Bitmap;
  import android.graphics.drawable.BitmapDrawable;
  import android.os.Bundle;
  import android.os.Environment;
  import android.os.Handler;
  import android.os.Looper;
  import android.os.Message;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemSelectedListener;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.Spinner;
  import android.widget.TextView;
  import android.magick.R;
  import magick.util.DisplayImageMetaData;
  import magick.util.MagickBitmap;
  
  import android.util.Log;
  import android.view.*;
  
  public class AndroidMagickActivity extends Activity {
      static final int PROGRESS_DIALOG = 0;
      ProgressDialog progressDialog = null;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
          // InputStream stream = getResources().openRawResource(R.raw.app_notes);
  
  
          try {
              final MagickImage img = new MagickImage(new ImageInfo("/sdcard/1.jpg"));
  
              /*
               * ImageView iv = new ImageView(this);
               * iv.setImageBitmap(MagickBitmap.ToBitmap(img));
               * setContentView(iv);
               */
  //          setContentView(R.layout.main);
              Spinner s = (Spinner) findViewById(R.id.spinner);
              ArrayAdapter adapter = ArrayAdapter.createFromResource(this,R.array.effects, android.R.layout.simple_spinner_item);
              adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              s.setAdapter(adapter);
  
              s.setOnItemSelectedListener(new OnItemSelectedListener() {
  
                  public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                          int pos, long id) {
                      ProgressThread t = new ProgressThread(img, pos);
                      //runOnUiThread(t);
                      t.run();
                  }
  
                  public void onNothingSelected(AdapterView&lt;?&gt; parent) {
                      // Do nothing.
                  }
              });
              ImageView iv = (ImageView) findViewById(R.id.imageView);
              iv.setImageBitmap(MagickBitmap.ToBitmap(img));
          } catch (MagickApiException e) {
              e.printStackTrace();
          } catch (MagickException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          /*
           * TextView tv = new TextView(this);
           * tv.setText(DisplayImageMetaData.displayMagickImage(img));
           * setContentView(tv);
           */
          int count = 2;
          MagickImage images[] = new MagickImage[count];
          for (int i = 0; i &lt; count; i++) {
              String path = "/sdcard/" + String.valueOf(i + 1) + ".jpg";
              try {
                  images[i] = new MagickImage(new ImageInfo(path));
              } catch (MagickException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
          try {
              MagickImage image = new MagickImage(images);
              image.setImageFormat("gif");
              String fn = Environment.getExternalStorageDirectory() + "/Pictures/test.gif";
              image.setFileName(fn);
              ImageInfo info = new ImageInfo(fn);
              info.setMagick("gif");
              //image.writeImage(info);
              byte blob[] = image.imageToBlob(info);
              FileOutputStream fos = new FileOutputStream(fn);
              fos.write(blob);
              fos.close();
              FileOutputStream testOS = new FileOutputStream("/mnt/sdcard/test.txt");
              testOS.write("abc".getBytes());
              testOS.close();
          } catch (MagickException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  
      protected Dialog onCreateDialog(int id, Bundle bundle) {
          switch (id) {
          case PROGRESS_DIALOG:
              /*
               * ProgressDialog dialog =
               * ProgressDialog.show(AndroidMagickActivity.this, "",
               * "Loading. Please wait...", true);
               */
              progressDialog = new ProgressDialog(AndroidMagickActivity.this);
              progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
              progressDialog.setMessage("Loading...");
              return progressDialog;
              // return dialog;
          default:
              return null;
          }
      }
  
  
      /** Nested class that performs progress calculations (counting) */
      private class ProgressThread extends Thread {
  
          MagickImage img;
          int pos;
  
          ProgressThread(MagickImage image, int pos) {
              this.img = image;
              this.pos = pos;
          }
  
          public void run() {
              int effect = 0;
              AndroidMagickActivity.this.showDialog(PROGRESS_DIALOG);
              switch (pos) {
              case 1:
                  effect = NoiseType.UndefinedNoise;
                  break;
              case 2:
                  effect = NoiseType.UniformNoise;
                  break;
              case 3:
                  effect = NoiseType.GaussianNoise;
                  break;
              case 4:
                  effect = NoiseType.MultiplicativeGaussianNoise;
                  break;
              case 5:
                  effect = NoiseType.ImpulseNoise;
                  break;
              case 6:
                  effect = NoiseType.LaplacianNoise;
                  break;
              case 7:
                  effect = NoiseType.PoissonNoise;
                  break;
              }
              Bitmap bitmap = null;
              try {
                  ImageView iv = (ImageView) findViewById(R.id.imageView);
  
                  MagickImage image = null;
                  if (pos &lt; 8)
                      image = img.addNoiseImage(effect);
                  else if (pos == 9)
                      image = img.blurImage(5, 1);
                  else if (pos == 10)
                      image = img.charcoalImage(5, 1);
                  else if (pos == 11)
                      image = img.edgeImage(0);
                  if (image != null) {
  
                      bitmap = MagickBitmap.ToBitmap(image);
                      iv.setImageBitmap(bitmap);
                  }
                  // bitmap.recycle(); we can't do that.
                  AndroidMagickActivity.this.dismissDialog(PROGRESS_DIALOG);
              } catch (MagickException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
      }    
  }
  </code></pre>