Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ColorConvert in JAI

7 views
Skip to first unread message

Weasel

unread,
Oct 3, 2002, 3:32:32 AM10/3/02
to
I have some code to make a color conversion:
String fileName = "images/Town.jpg";
FileSeekableStream fss = new FileSeekableStream(fileName);
RenderedOp rop = JAI.create("JPEG", fss);
ICC_Profile iccProfile =
ICC_Profile.getInstance(ColorSpace.CS_sRGB);
ICC_ColorSpace iccColorSpace = new ICC_ColorSpace(iccProfile);
ParameterBlock pb = new ParameterBlock();
pb.addSource(rop);
pb.add(iccColorSpace);
RenderedOp ropGray = JAI.create("ColorConvert", pb);

When I run it I get the following exception:
ava.lang.IllegalArgumentException: ColorConvert - Parameter value`s
class (java.awt.color.ICC_ColorSpace) is not an instance of the
parameter class (java.awt.image.ColorModel) for parameter
"colorModel".
at javax.media.jai.JAI.createNS(JAI.java:900)
at javax.media.jai.JAI.create(JAI.java:786)
at javax.media.jai.JAI.create(JAI.java:1198)
at wesslan.imaging.TestJAI.<init>(TestJAI.java:25)
at wesslan.imaging.TestJAI.main(TestJAI.java:138)
Exception in thread "main"

According to the JAI guide it is a ColorSpace that is the input param
to this method but the exception says it must be a ColorModel...
Do someone know how to get a ColorModel from a ColorSpace? I know
there is a constructor with a ColorSpace but it is not so intiutive...

Regards Weasel

0 new messages