Android - draw a bitmap as one color

I have several bitmaps (game sprites) that I would like to draw in a different bitmap, however, each opaque pixel of the original bitmap must be drawn using the same color, ignoring the original color of the source pixel. Basically, I am trying to use a sprite as a “stamp” of the same color that needs to be inserted into the destination bitmap.

I believe that I should use canvas.drawBitmap (Bitmap bitmap, matrix matrix, Paint Paint), however I'm not quite sure how I should initialize the paint object. Is this approach right?

+3
source share
2 answers

, , Paint.setColorFilter() PorterDuff.Mode.SRC_ATOP

myPaint.setColorFilter(new PorterDuffColorFilter(myColor, PorterDuff.Mode.SRC_ATOP));
+7

, ( Paint.) , , xfermode Porter-Duff SrcIn (Source In.)

0

Source: https://habr.com/ru/post/1781045/


All Articles