>颜色烧伤
>乘以
>变暗
>减轻
>叠加
(更多信息:http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-77eba.html)
例如,对于模式color Burn“查看每个通道中的颜色信息,并通过增加两者之间的对比度来使基色变暗以反映混合颜色.与白色混合不会产生任何变化”.
这是我的代码:
Bitmap blendBitmap = BitmapFactory.decodeStream(ctx.getAssets().open(filename));Canvas canvas = new Canvas(srcBitmap);canvas.drawBitmap(blendBitmap,null); // ?p.recycle();p = null;
是否可以应用color Burn混合模式而不是简单地将图像绘制在其他图像上方(如此小代码中)?
解决方法 这并不困难.我使用NDK(因为性能)来处理像素.混合模式的这些信息非常有用:How does photoshop blend two images together?
我的最终解决方案是:
#define ChannelBlend_colorBurn(A,B) ((uint8_t) ((B == 0) ? B : max(0,(255 - ((255 - #define ChannelBlend_Alpha(A,B,O) ((uint8_t) (O * A + (1 - O) * B))#define ChannelBlend_AlphaF(A,F,O) (ChannelBlend_Alpha(F(A,B),A,O))typedef struct { uint8_t red; uint8_t green; uint8_t blue; uint8_t Alpha;} rgba;// BlendJNIEXPORT voID JNICALL Java_com_package_Filter_jniBlend(jnienv* env,jobject obj,jobject bitmapA,jobject bitmapB,jobject bitmapOut,jint mode) { // PropertIEs AndroIDBitmAPInfo infoA; voID* pixelsA; AndroIDBitmAPInfo infoB; voID* pixelsB; AndroIDBitmAPInfo infoOut; voID* pixelsOut; int ret; // Get image info if ((ret = AndroIDBitmap_getInfo(env,bitmapA,&infoA)) < 0 || (ret = AndroIDBitmap_getInfo(env,bitmapB,&infoB)) < 0 || (ret = AndroIDBitmap_getInfo(env,bitmapOut,&infoOut)) < 0) { return; } // Check image if (infoA.format != ANDROID_BITMAP_FORMAT_RGBA_8888 || infoB.format != ANDROID_BITMAP_FORMAT_RGBA_8888 || infoOut.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { return; } // Lock all images if ((ret = AndroIDBitmap_lockPixels(env,&pixelsA)) < 0 || (ret = AndroIDBitmap_lockPixels(env,&pixelsB)) < 0 || (ret = AndroIDBitmap_lockPixels(env,&pixelsOut)) < 0) { LOGE("Error! %d",ret); } int h = infoA.height; int w = infoA.wIDth; int wh = w * h; int n; rgba* inputA = (rgba*) pixelsA; rgba* inputB = (rgba*) pixelsB; rgba* output = (rgba*) pixelsOut; rgba pA,pB; int x,y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { n = y * w + x; pA = inputA[n]; pB = inputB[n]; float Alpha = (float) pB.Alpha / 255.0; output[n].red = ChannelBlend_AlphaF(pA.red,pB.red,ChannelBlend_colorBurn,Alpha); output[n].green = ChannelBlend_AlphaF(pA.green,pB.green,Alpha); output[n].blue = ChannelBlend_AlphaF(pA.blue,pB.blue,Alpha); } } // Unlocks everything AndroIDBitmap_unlockPixels(env,bitmapA); AndroIDBitmap_unlockPixels(env,bitmapB); AndroIDBitmap_unlockPixels(env,bitmapOut);}
提高性能的小注意事项:在我为单个像素制作公式后,最好将值存储在某种缓存中,以便在下次没有公式的情况下更快地访问它.
总结以上是内存溢出为你收集整理的android – PNG混合模式全部内容,希望文章能够帮你解决android – PNG混合模式所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)