如何在位图上应用不同的图像效果(滤镜),如棕褐色,黑白,模糊等?

问题描述 投票:11回答:5

我不知道如何对图像应用不同的效果,

我已经看到EffectFactory类和Effect类在效果类中有一种方法apply但我不知道在inputTexId和optputTexId中传递什么,并且从我获得新的更新图像,如何在imageView中存储更新的图像,

请帮我解决这个问题。是否有任何开源库可用于为Image提供效果。

谢谢,

android image-processing android-image image-editing
5个回答
9
投票

我已经实施了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上查找更多详细信息


6
投票

您可以使用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();

5
投票

是的,你可以使用鸟舍sdk使用很多效果..

访问http://www.aviary.com/android

对于更高级的效果,您可以使用Opencv ..这些是最好的..


2
投票

你也可以尝试this项目它处理一些Bitmap Processing

过滤器: -

  • 提升颜色
  • 亮度
  • 颜色深度
  • 彩色滤光片
  • 对比
  • 浮雕
  • 翻转和旋转
  • 伽玛
  • 高斯模糊
  • 灰度
  • 色调
  • 倒置
  • 噪声
  • 饱和
  • 乌贼
  • 削尖
  • 草图
  • 着色
  • 小插图

由于它是在Java中并且进行像素标签处理,因此它没有大多数基于C ++的库那么快,但如果位图大小不是很大,例如缩略图,它的效果很好。


1
投票

这是一个优秀的图书馆,易于与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);
© www.soinside.com 2019 - 2024. All rights reserved.