java - What color blending algorithm is used to darken a color? -
i have these cards have 2 color shades on them. main color, , darker accent color:
the main color given me in hex, not accent. can tell kind of blend or transformation being done argb of main color darker accent color?
if matters, i'm developing against android i've got access color class , colorfilter can apply porterduff stuff...
if want darker color
, can:
- convert rgb hsv
rgbtohsv()
. - reduce v (lightness value). it's
hsv[2]
, float value 0 1. - convert hsv
color
hsvtocolor()
.
if want darker bitmap
, porterduff.mode.darken
should work. need calibrate color
value:
private bitmap getdarkerbitmap(bitmap src) { final int color = 0xaaffffff; final int width = src.getwidth(); final int height = src.getheight(); final bitmap result = bitmap.createbitmap(width, height, src.getconfig()); final bitmapdrawable drawable = new bitmapdrawable(src); drawable.setbounds(0, 0, width, height); drawable.setcolorfilter(color, porterduff.mode.darken); drawable.draw(new canvas(result)); return result; }
Comments
Post a Comment