安卓 - 图像处理速度慢



我正在为Android做一个用于图像处理的应用程序。

为了更快地做事,我曾经对示例图像应用过滤器(使用 inSampleSize 作为谷歌推荐)

当我保存照片(并将效果应用于原始图像)时,该过程大约需要 16 秒才能完成(Galaxy Nexus 为 5 mpx),所以我在想是否有更快的方法来处理图像。

这是我将效果应用于真实图像的代码:

public void executeRealEffect(FileOutputStream ostream)
        throws InstantiationException, IllegalAccessException,
        ClassNotFoundException {//...
    ImageProcessing imp;
    imp = (ImageProcessing) Class.forName(effectUsed).newInstance();
    savePhoto = imp.doEffect(BitmapFactory.decodeFile(pathToPhotoUsed)); 
    savePhoto.compress(CompressFormat.JPEG, 100, ostream);//...
}

这是从互联网上获取的效果,以尝试该应用程序:http://xjaphx.wordpress.com/2011/06/21/image-processing-grayscale-image-on-the-fly/

您可以使用这些点

BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 4;
savePhoto.compress(CompressFormat.JPEG, 0, ostream);
savePhoto = imp.doEffect(BitmapFactory.decodeFile(pathToPhotoUsed,options));

最新更新