Change BufferedImage color

Hello everyone I am calculating a fractal and drawing a bufferedImage based on the number of completedInterfaces. For simplicity's sake, I can colorize bufferdImage with completed instances like this:

g.setColor(Color.getHSBColor((float) (colorValue - completedIterations), 1F, 1F));


If colourValue is constant when creating the image, say 0.2 in this case.

I have a slider on a JPanel that, when used, changes the colorValue in the range 0 to 1. When the colorValue value changes, I want to update the BufferedImage in real time, but I don't want to recalculate all the points of the image as it causes significant overhead - I just want to recolor the BufferedImage based on the new colorValue.

Is it possible to do this, and if so, how should I implement it?




source to share

1 answer

You can set individual pixels with setRGB()

as shown here ; or adjust a few pixels with RescaleOp

as shown here .



All Articles