Home » Category » Java Programming

Java Programming: zooming changes the color..

300| Sat, 22 Sep 2007 02:49:00 GMT| olzen| Comments (4)
When I use this code to scale bufferedImages of TYPE_USHORT_GRAY or TYPE_BYTE_GRAY, the image returned is brighter than the one passed to the method?
Does anyone have any idea of what I am doing wrong here?
Thanx in advance.

public BufferedImage scale_ (BufferedImage img, double magFactor)
{
int imgWidth = (int) (img.getWidth()* magFactor);
int imgheight = (int) (img.getHeight() * magFactor);
displayImage = new BufferedImage ( imgWidth, imgheight, img.getType() );
Graphics2D g = (Graphics2D) displayImage.getGraphics();
g.drawImage( img, 0, 0, imgWidth, imgheight, null);
return displayImage;
}

Keywords & Tags: zooming, changes, color, java, programming

URL: http://java.itags.org/java-programming/332344/
 
«« Prev - Next »» 4 helpful answers below.

I would be interested to see what the result would be if you used a color gradation panel with blocks of graduated shades of grey.

One possible answer is that as it expands the image it is dithering (or anti-aliasing) the image which is causing the effect you're noticing.

No idea off hand how to prove that, or how to prevent it, but those were the thoughts I had when reading your question.

puckstopper31 | Fri, 29 Jun 2007 10:41:00 GMT |

Is it really, of does it just appear to be because the scaling is causing doubling of pixels, thus giving an appearance of a brighter image... Presumably, it would appear brigher when larger, darker when smaller.... Just a guess, though.

bsampieri | Fri, 29 Jun 2007 10:41:00 GMT |

>Presumably, it would appear brigher when larger, darker when smaller.Nope it is gettiging brighter for both larger and smaler images. but thanx for the suggestion.

olzen | Fri, 29 Jun 2007 10:41:00 GMT |

Problem solved. This occur in java 1.3.0, java 1.4.X solves this problem.Thanks for the suggestions both of you!Olzen

olzen | Fri, 29 Jun 2007 10:41:00 GMT |

Java Programming Hot Answers

Java Programming New questions

Java Programming Related Categories