开发者

Android: image doesn't keep it's original color with use of canvas.drawBitmap

I'm developing an android app and I'm facing a weird issue. I'm doing some image processing on a SurfaceView. I'm drawing the processed image using a canvas and the following method:

canvas.drawBitmap(image, x, y, paint)

My SurfaceView has a colored background (#3500ffff, kind of very dark green) and once the image is drawn, I can notice that its original colors are not conserved. It has a very slight dark green tint, like if the bitmap alpha was changed.

Did anyone already encounter this issue? Would you have an idea o开发者_StackOverflow中文版n how to fix this?


This would happen with a 16 bits destination. 16 bits buffers encode pixels in 565 format, which gives you a higher precision in the green channel, which sometimes result in greenish tints. A 32 bits destination/bitmap would solve this issue.


Presuming that your image is not transparent how did you define paint, it should not be a transparent colour or use some special effect. Try using null for paint.

The other thing is what are you drawing first the image or the background? Just wondering if your drawing order is correct.

If you set your surface to be non-transparent will the image change colour then?

Another thing I noticed which I think is connected with events sychronisation is that sometimes drawing on surface creates a semi-transparent sprite when moving the finger very fast over the screen which initialises drawing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜