I must note that I'm not too familiar with the Java2D API, but while working on 
a little project of mine (which involves reading packed RGB values directly 
from a Raster's DataBuffer), I noticed the following behavior when trying to 
convert from BufferedImages that use the sRGB color space to ones that use 
linear RGB.

Assuming [i]sRGBImg[/i] uses the sRGB color space and [i]linearImg[/i] uses a 
linear RGB space, the following methods of transferring image data from sRGBImg 
to linearImg deliver different results:

Method1:
Graphics2D g = linearImg.createGraphics();
g.drawImage(sRGBImg, 0, 0, null);

Method2:
new ColorConvertOp(null).filter(sRGBImg, linearImg);

I thought, that drawImg would perform color space conversion if the source 
image was in a different color space that whatever one is drawing to. However, 
it appears that no color space conversion is performed with method 1, whereas 
color values are converted when performing method 2. As a sidenote, the image 
created with method 1 renders correctly when used in some component's painting 
code, whereas the one created with method 2 does not (probably because 
transformation to the target color space is ignored when painting as well).

BTW: RenderingHints set for the Graphics2D / the ColorConvertOp do not appear 
to make any difference.

Just curious: Is this the expected behavior of Graphics2D#drawImage? If so, is 
this guaranteed somewhere so that I can rely on it for future endeavors?
[Message sent by forum member 'ingomar_wesp' (ingomar_wesp)]

http://forums.java.net/jive/thread.jspa?messageID=328240

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

Reply via email to