Negative RGB-values from BufferedImage

P

Peter the Swede

Best groupmember,

I have an BufferedImage that works fine and is correct when I view it as
graphics. The problem I have is that the method getRGB(int x, int y) returns
negative values. Anyone who have experience of this? When I have used it
before I have always got positiv values.

Cheers, Peter

To read the BufferedImage I use:
myImage = (BufferedImage) ImageIO.read(new File(myHoleImageFileName));

To save it I do:
String holeImageFileName = myCourse.getCourseID() + "_" +
tempHole.getHoleID() + ".him";

tempHole.setHoleImageFileName(holeImageFileName);

Iterator writers = ImageIO.getImageWritersByFormatName("png");


ImageWriter writer = (ImageWriter)writers.next();

f = new File(holeImageFileName);

ImageOutputStream ios = ImageIO.createImageOutputStream(f);

writer.setOutput(ios);

writer.write(tempHole.getImage());

ios.close();
 
C

Chris Smith

Peter said:
Best groupmember,

I have an BufferedImage that works fine and is correct when I view it as
graphics. The problem I have is that the method getRGB(int x, int y) returns
negative values. Anyone who have experience of this? When I have used it
before I have always got positiv values.

Since the value returned is encoded with TYPE_INT_ARGB, a "negative"
return value simply means that you've got greater than 50% alpha in the
pixel. That's nothing out of the ordinary!

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
P

Peter the Swede

Thanks Chris, Cheers...

Chris Smith said:
Since the value returned is encoded with TYPE_INT_ARGB, a "negative"
return value simply means that you've got greater than 50% alpha in the
pixel. That's nothing out of the ordinary!

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

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,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top