T
Tim
I'm trying to read a png image file, change some colors, and write it back
out to a file.
My code so far is below. Can anyone tell me (specifically - details please)
how to write the modified pixels out to a new file or change the existing
file and save the change? Every time I try to write it out the color
changes don't show up, even if I just set all pixels to black.
Thanks,
Tim
----------------------
File imgFile = new File("myImage.png");
// get BufferedImage
BufferedImage image = ImageIO.read(imgFile);
int x = image.getMinX();
int y = image.getMinY();
int w = image.getWidth();
int h = image.getHeight();
// get image pixels
int[] oldPixels = new int[w * h];
PixelGrabber grabber = new PixelGrabber(image, x, y, w, h, oldPixels, 0,
w);
// modify pixels
int[] newPixels = replaceColor(oldPixels);
// NOW WHAT? How to write to a file?
out to a file.
My code so far is below. Can anyone tell me (specifically - details please)
how to write the modified pixels out to a new file or change the existing
file and save the change? Every time I try to write it out the color
changes don't show up, even if I just set all pixels to black.
Thanks,
Tim
----------------------
File imgFile = new File("myImage.png");
// get BufferedImage
BufferedImage image = ImageIO.read(imgFile);
int x = image.getMinX();
int y = image.getMinY();
int w = image.getWidth();
int h = image.getHeight();
// get image pixels
int[] oldPixels = new int[w * h];
PixelGrabber grabber = new PixelGrabber(image, x, y, w, h, oldPixels, 0,
w);
// modify pixels
int[] newPixels = replaceColor(oldPixels);
// NOW WHAT? How to write to a file?