Faster way to set a (PNG) bitmap color instead of pixel by pixel

前端 未结 2 1854
礼貌的吻别
礼貌的吻别 2020-12-21 22:07

I have some png files that I am applying a color to. The color changes depending on a user selection. I change the color via 3 RGB values set from another method. The png

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-21 22:34

    The answer that worked for me was a write up Square did here Transparent jpegs

    They provide a faster code snippet for doing this exact thing. I tried extractAlpha and it didn't work but Square's solution did. Just modify their solution to instead modify the color bit and not the alpha bit.

    i.e.

    pixels[x] = (pixels[x] & 0xFF000000) | (color & 0x00FFFFFF);
    

提交回复
热议问题