Original Post
🔒 Locked
[java] Darken a BufferedImage
Advertisement
hi h_o_p_s
affineTransformation seems to be the wrong way as it's working only a coordinates not on color values.. i'm not sure if this can be done with the colorConvert class... a straight forward approch would be to loop through all pixels and set there rgbValue to (getRgb * alpha) where alpha is a number between 0 and 1 representing the darkening you want to achieve..
hope this helps..
i'll took a deeper look into that colorConvert...maybe i'll find something useful
good luck!
affineTransformation seems to be the wrong way as it's working only a coordinates not on color values.. i'm not sure if this can be done with the colorConvert class... a straight forward approch would be to loop through all pixels and set there rgbValue to (getRgb * alpha) where alpha is a number between 0 and 1 representing the darkening you want to achieve..
hope this helps..
i'll took a deeper look into that colorConvert...maybe i'll find something useful
good luck!
This seems to be what you seek. FYI, that site is a great resource for such things. If you didn't want to read, here's the relevant snippet :
Yeah, "RescaleOp" is a bit misleading, but it does what you want [grin].
// Darken the image by 10%float scaleFactor = .9f; // out of 100 ... obviouslyRescaleOp op = new RescaleOp(scaleFactor, 0, null);bufferedImage = op.filter(bufferedImage, null);Yeah, "RescaleOp" is a bit misleading, but it does what you want [grin].
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
