Skip to content
Advertisement

How to ignore pixels when merging bitmaps?

It’s my merging code

JavaScript

how it works But I want to merge it without overlay black pixels. P.S. qr-code image is not transparent, green image not visible behind qr

Advertisement

Answer

The easiest way is to use a Paint when drawing the overlay (green) Bitmap, but I’m not sure which parameter to use as PorterDuff.Mode (reference):

JavaScript

But if you have already tried all values without success, then you have to subtract black pixels from the overlay (the green one) before draw this latest. Steps:

  1. remove all white pixels from QRCode Bitmap
  2. subtract remaining black pixels to the green overlay (in this way the green area will have holes inside it)
  3. draw the green overlay as usual
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement