Skip to main content

[JAVA2D] Failing to Display correct ICC colors

1 reply [Last post]
Anonymous

I'm trying to display an ICC correct image.
In order to test it I changed my monitor profile to a very distorted one.
Photoshop shows a distorted color image.
My Java program shows a normal color image.

Platforms are Win 2000 and Mac OSX, JDK 1.4

Here is the code, what am I doing wrong?

package testMonitorICC;

import javax.swing.JComponent;

import java.awt.image.*;
import java.awt.color.*;
import java.io.*;

import javax.imageio.*;
import javax.imageio.stream.*;
import java.awt.geom.*;
import java.util.*;
import java.awt.*;

class ImageComponent extends JComponent
{

public ImageComponent()
{
setImage("test.jpg");
}

void setImage (String fileName)
{
try
{
mImage = decodeAsBufferedImage(fileName);
setPreferredSize(new Dimension(mImage.getWidth(),
mImage.getHeight()));
}
catch (IOException ex)
{
}
}

public void paintComponent(Graphics graphics)
{
Graphics2D graphics2D = (Graphics2D) graphics;
graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics2D.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
graphics2D.drawImage(mImage, null, 0,0);
}

private BufferedImage decodeAsBufferedImage(String fullPathName) throws
java.io.IOException
{
return ImageIO.read(new File(fullPathName));
}

private BufferedImage mImage;

}

____________________________________________________________________________
__________
Sergio Nacht
Software Development Team Leader

Leaf Digital Photography Products
Creo Corporation ltd.
Tel: +972-9-9597592 Fax: +972-9-9529143
mailto:sergio.nacht@creo.com
www.creo.com/leaf
____________________________________________________________________________
__________

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dave Kavanagh

Sergio,
I know you can load the profile yourself and set up a color transform on the
graphics object before calling drawImage(). I'm not sure about getting it
applied automaticly.

David

Quoting Sergio Nacht :

> I'm trying to display an ICC correct image.
> In order to test it I changed my monitor profile to a very distorted one.
> Photoshop shows a distorted color image.
> My Java program shows a normal color image.
>
> Platforms are Win 2000 and Mac OSX, JDK 1.4
>
> Here is the code, what am I doing wrong?
>
> package testMonitorICC;
>
> import javax.swing.JComponent;
>
> import java.awt.image.*;
> import java.awt.color.*;
> import java.io.*;
>
> import javax.imageio.*;
> import javax.imageio.stream.*;
> import java.awt.geom.*;
> import java.util.*;
> import java.awt.*;
>
> class ImageComponent extends JComponent
> {
>
> public ImageComponent()
> {
> setImage("test.jpg");
> }
>
> void setImage (String fileName)
> {
> try
> {
> mImage = decodeAsBufferedImage(fileName);
> setPreferredSize(new Dimension(mImage.getWidth(),
> mImage.getHeight()));
> }
> catch (IOException ex)
> {
> }
> }
>
> public void paintComponent(Graphics graphics)
> {
> Graphics2D graphics2D = (Graphics2D) graphics;
> graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING,
> RenderingHints.VALUE_RENDER_QUALITY);
> graphics2D.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
> RenderingHints.VALUE_COLOR_RENDER_QUALITY);
> graphics2D.drawImage(mImage, null, 0,0);
> }
>
> private BufferedImage decodeAsBufferedImage(String fullPathName) throws
> java.io.IOException
> {
> return ImageIO.read(new File(fullPathName));
> }
>
> private BufferedImage mImage;
>
> }
>
> ____________________________________________________________________________
> __________
> Sergio Nacht
> Software Development Team Leader
>
> Leaf Digital Photography Products
> Creo Corporation ltd.
> Tel: +972-9-9597592 Fax: +972-9-9529143
> mailto:sergio.nacht@creo.com
> www.creo.com/leaf
> ____________________________________________________________________________
> __________
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>

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