本文介绍了模糊和浮雕图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的一个Android应用程序,而我有我从源图像装载了一个可绘制。在这个图片我想做出一个图像模糊和embross,我读的
你能给我一些建议吗?谢谢
编辑:我有浮雕的形象,但我不能蓝色的图像,你能不能给我一些蓝色
解决方案
公共位图fudiao(位图bmpOriginal){
INT宽度,高度,R,G,B,C,一个,暗淡,C1,A1,R1,G1,B1,红,绿,蓝;
身高= bmpOriginal.getHeight();
宽度= bmpOriginal.getWidth();
INT深度= 30;
位图bmpSephia = Bitmap.createBitmap(宽度,高度,Bitmap.Config.RGB_565);
帆布油画=新的Canvas(bmpSephia);
涂料粉刷=新的油漆();
//嘉洛斯厘米=新嘉洛斯();
// cm.setScale(.3f,.3f,.3f,1.0F);
// ColorMatrixColorFilter F =新ColorMatrixColorFilter(厘米);
// paint.setColorFilter(F);
canvas.drawBitmap(bmpOriginal,0,0,NULL);
对于(INT Y = 1; Y<高度-1; Y ++){
为(中间体X = 1; X&所述;宽度-1; X ++){
C = bmpOriginal.getPixel(X,Y);
R = Color.red(C);
G = Color.green(C);
B = Color.blue(C);
C1 = bmpOriginal.getPixel(X-1,Y-1);
R1 = Color.red(C1);
G1 = Color.green(C1);
B1 = Color.blue(C1);
红色= Math.max(67,Math.min(255,Math.abs(R - R1 + 128)));
绿色= Math.max(67,Math.min(255,Math.abs(G - G1 + 128)));
蓝色= Math.max(67,Math.min(255,Math.abs(B - B 1 + 128)));
如果(红> 255)
{
红= 255;
}
否则,如果(红℃下)
{
红色= 0;
}
如果(绿色> 255)
{
绿色= 255;
}
否则,如果(绿色℃下)
{
绿色= 0;
}
如果(蓝色> 255)
{
蓝色= 255;
}
否则,如果(蓝色℃下)
{
蓝色= 0;
}
bmpSephia.setPixel(X,Y,Color.rgb(红,绿,蓝));
// bmpSephia.setPixel(X,Y,Color.argb(A1,红色,绿色,蓝色));
}
}
返回bmpSephia;
}
这只是一个压印PIC
I'm working on an android application, and I have a drawable that I'm loading up from a source image. On this image i want make a image blur and embross ,i have read How to change colors of a Drawable in Android?
can you give me some advice?thank you
edit:i have emboss an image,but i cannot blue an image,can you give me some blue
解决方案
public Bitmap fudiao(Bitmap bmpOriginal) {
int width, height, r,g, b, c,a, gry,c1,a1,r1,g1,b1,red,green,blue;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
int depth = 30;
Bitmap bmpSephia = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bmpSephia);
Paint paint = new Paint();
// ColorMatrix cm = new ColorMatrix();
// cm.setScale(.3f, .3f, .3f, 1.0f);
// ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
// paint.setColorFilter(f);
canvas.drawBitmap(bmpOriginal, 0, 0, null);
for(int y=1; y< height-1; y++) {
for(int x=1; x < width-1; x++) {
c = bmpOriginal.getPixel(x, y);
r = Color.red(c);
g = Color.green(c);
b = Color.blue(c);
c1 = bmpOriginal.getPixel(x-1, y-1);
r1 = Color.red(c1);
g1 = Color.green(c1);
b1 = Color.blue(c1);
red = Math.max(67, Math.min(255, Math.abs(r - r1 + 128)));
green = Math.max(67, Math.min(255, Math.abs(g - g1 + 128)));
blue = Math.max(67, Math.min(255, Math.abs(b - b1 + 128)));
if (red > 255)
{
red = 255;
}
else if (red < 0)
{
red = 0;
}
if (green > 255)
{
green = 255;
}
else if (green < 0)
{
green = 0;
}
if (blue > 255)
{
blue = 255;
}
else if (blue < 0)
{
blue = 0;
}
bmpSephia.setPixel(x, y, Color.rgb(red, green, blue));
// bmpSephia.setPixel(x, y, Color.argb(a1, red, green, blue));
}
}
return bmpSephia;
}
this only emboss a pic
这篇关于模糊和浮雕图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!