我不知道如何对图像应用不同的效果,
我已经看到EffectFactory类和Effect类在效果类中有一种方法apply但我不知道在inputTexId和optputTexId中传递什么,并且从我获得新的更新图像,如何在imageView中存储更新的图像,
请帮我解决这个问题。是否有任何开源库可用于为Image提供效果。
谢谢,
我已经实施了Jerry's Java Image Processing Library。对我来说很好。
下载AndroidJars。
编辑
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//Find the bitmap's width height
int width = AndroidUtils.getBitmapOfWidth(getResources(), R.drawable.ic_launcher);
int height = AndroidUtils.getBitmapOfHeight(getResources(), R.drawable.ic_launcher);
//Create a filter object.
GaussianFilter filter = new GaussianFilter();
//set???? function to specify the various settings.
filter.setRadius(8.5f);
//Change int Array into a bitmap
int[] src = AndroidUtils.bitmapToIntArray(bitmap);
//Applies a filter.
filter.filter(src, width, height);
//Change the Bitmap int Array (Supports only ARGB_8888)
Bitmap dstBitmap = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);
在Android-jhlabs上查找更多详细信息
您可以使用Catalano Framework:
http://code.google.com/p/catalano-framework/
FastBitmap image = new FastBitmap(bitmap);
image.toRGB();
//Sepia
Sepia sepia = new Sepia();
sepia.applyInPlace(image);
//Blur
Blur blur = new Blur();
blur.applyInPlace(image);
//Emboss
Emboss emboss = new Emboss();
emboss.applyInPlace(image);
//Retrieve bitmap
bitmap = fb.toBitmap();
你也可以尝试this项目它处理一些Bitmap Processing
过滤器: -
由于它是在Java中并且进行像素标签处理,因此它没有大多数基于C ++的库那么快,但如果位图大小不是很大,例如缩略图,它的效果很好。
这是一个优秀的图书馆,易于与gradle集成,它快速高效,节省了我的一天:
https://github.com/wasabeef/picasso-transformations
这是它如何使用的一个例子:
Transformation trans1 = new ContrastFilterTransformation(getActivity(), 1.5f);
Transformation trans2 = new BrightnessFilterTransformation(getActivity(), 0.2f);
Picasso.with(getActivity()).load(uri)
.transform(trans1).transform(trans2).into(imageview3);