Posted By:
Matt_Mead
Posted On:
Monday, January 14, 2002 10:20 AM
I'm porting an image resampling algorithm to Java and using the JAI to perform input/output of images. I'd port the algorithm to the Interpolation abstraction, but the algorithm changes based on several things, and doesn't quite fit the abstraction. Anyway, I'm running into trouble with certain image formats. If I load a JPG, things work fine. However, if I load a PNG, things fail. The BufferedImage returned has a type of TYPE_CUSTOM ((int) 0). Its SampleModel is PixelInterleavedSampleModel, its ColorModel is ComponentColorModel. I've been using ColorModel.get{Red,Green,Blue,Alph} and/or getComponents but on PNG images these throw an exception because there is more than one component involved in getting the individual values.
More>>
I'm porting an image resampling algorithm to Java and using the JAI to perform input/output of images. I'd port the algorithm to the Interpolation abstraction, but the algorithm changes based on several things, and doesn't quite fit the abstraction.
Anyway, I'm running into trouble with certain image formats. If I load a JPG, things work fine. However, if I load a PNG, things fail. The BufferedImage returned has a type of TYPE_CUSTOM ((int) 0). Its SampleModel is PixelInterleavedSampleModel, its ColorModel is ComponentColorModel.
I've been using ColorModel.get{Red,Green,Blue,Alph} and/or getComponents but on PNG images these throw an exception because there is more than one component involved in getting the individual values.
How can I write code that will get the color values out of any BufferedImage to work with them?
Thanks!
-matt
<<Less