changing the intensity of lighten/darken on bitmap

2019-04-12 06:44发布

Ok my orignal question has changed. How do i change the intensity of how something like this is effected?

    DayToNight.setXfermode(new PorterDuffXfermode(Mode.DST_IN));

in my dream world it would have worked like this

    DayToNight.setXfermode(new PorterDuffXfermode(Mode.DST_IN(10)));

the 10 being a level of intensity.


An example would be if I had a flickering candle, when the candle burns bright I want the bitmaps I am drawing to the screen to retain their origanol color and brightness, when it flickers I want the bitmaps to be almost blacked out, and I want to darken the Bitmaps as the light dims.

I have equations, timers and all that figured out, just not how to actually apply it to change the color/brightness. Maybe burning the images is what im looking for? I just want to change the lightness lol.

I feel like using paint.setShader might be a solution, but the information in this area is pretty limited from what i have been able to find. Any help would be appreciated.

edit: to be crystal clear, i am looking for a way to lighten/darken bitmaps as I draw them to the canvas

2条回答
够拽才男人
2楼-- · 2019-04-12 07:07

These two approaches may solve your problem:

  1. Put a dark rectangle behind your bitmap and set the Bitmap's opacity.

  2. Use ColorFilter on your Paint when you draw the bitmap. To darken your bitmap use a semi-transparent black color

查看更多
【Aperson】
3楼-- · 2019-04-12 07:16

Hey I have used a kind of trick to remove the black line.In my erase button, I have set the color to white, instead of using XferMode.. It works and looks good..

if(erase){
paintColor = Color.parseColor(newColor);
drawPaint.setColor(paintColor);
}
查看更多
登录 后发表回答