加载图片效果在Android中占用了大量时间?

时间:2013-01-30 09:56:58

标签: android image-processing

我正在开发一个基于图像处理的项目,我正在编辑具有40多种不同效果的任何单个图像,如棕褐色,浮雕,雕刻等。现在问题是每当我使用任何高分辨率高清图像时,它需要一个大量时间至少15分钟加载该图像的所有效果。如何减少这个时间,我没有使用OpenCV API。以下是我的代码。

   public class Image_add_effects extends Activity implements OnClickListener{
ImageView image;
HorizontalScrollView view;

ImageView mSwitcher;
ArrayList<Bitmap>array_image;
Bitmap image_compress;
 BitmapDrawable drawable,drawable_image;
 Bitmap changed_image;
 Gallery g;
 ImageView img1,img2,img3,img4,img5;
 Bitmap bit1,bit2,bit3,bit4,bit5;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.add_effects);
    setBodyUi();
    System.loadLibrary("PhotoProcessing");

     changed_image=Image_effects.image_change;
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     //System.out.println("yourSelectedImage"+yourSelectedImage);
     changed_image.compress(Bitmap.CompressFormat.JPEG, 100, stream); 

    new SendImage().execute();
}

public class SendImage extends AsyncTask<String, Process, String> {

    ProgressDialog pb;
    String the_string_response;
    String image_str;

    @Override
    public void onPreExecute() {

        pb = ProgressDialog
                .show(Image_add_effects.this, null, "Processing....");


    }

    @Override
    protected String doInBackground(String... params) {




        bit1=(Effects_change.doInvert(image_compress));
        bit2=(Effects_change.doHighlightImage(image_compress));
        bit3=(Effects_change.applyGaussianBlur(image_compress));
        bit4=(Effects_change.sharpen((image_compress),20));
        bit5=(Effects_change.applyMeanRemoval(image_compress));
        bit6=(Effects_change.smooth((image_compress),8));
        bit7=(Effects_change.emboss(image_compress));
        bit8=(Effects_change.engrave(image_compress));
        bit9=(Effects_change.applyHueFilter((image_compress),9));

        bit10=(Effects_change.doGreyscale(image_compress));
        bit11=(Effects_change.doGamma((image_compress),0.6, 0.6, 0.6));
        bit12=(Effects_change.doGamma((image_compress),1.8, 1.8, 1.8));
        bit13=(Effects_change.doColorFilter((image_compress), 1.0, 0, 0));
        bit14=(Effects_change.doColorFilter((image_compress), 0, 1, 0));
        bit15=(Effects_change.doColorFilter((image_compress), 0, 0, 1));
        bit16=(Effects_change.doColorFilter((image_compress), 0.5, 0.5, 0.5));
        bit17=(Effects_change.doColorFilter((image_compress), 1.5, 1.5, 1.5));
        bit18=(Effects_change.createSepiaToningEffect((image_compress),100, 1.5, 0.6, 0.12));
        bit19=(Effects_change.createSepiaToningEffect((image_compress),200, 0.88, 2.45, 1.43));
        bit20=(Effects_change.createSepiaToningEffect((image_compress),255, 1.2, 0.87, 2.1));

        return null;
    }

    @Override
    public void onPostExecute(String result) {
        super.onPostExecute(result);

        img1.setImageBitmap(bit1);
        img2.setImageBitmap(bit2);
        img3.setImageBitmap(bit3);
        img4.setImageBitmap(bit4);
        img5.setImageBitmap(bit5);

        pb.dismiss();
    }

}

我在上面的代码中使用此链接: http://xjaphx.wordpress.com/2011/06/21/image-processing-grayscale-image-on-the-fly/

当我正在制作一个Android应用程序时,由于我是Image Processing的新手,因此我很难做同样的事情。如何为图像添加效果?

1 个答案:

答案 0 :(得分:0)

尝试使用Catalano Framework。这是解释如何使用的article