Create png image file

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?
 
J

jan V

I'm trying to read a png image file, change some colors, and write it back
out to a file.

You've already asked this question a few days ago, and the answer has
remained the same. Can you stop asking this question when you've been given
the answer???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top