Link to home
Start Free TrialLog in
Avatar of krisjburn
krisjburn

asked on

Image manipulation using JAI

I've created a java class, using the tutorials on the sun web site, that displays an image to the screen together with the function to zoom in on a highlighted area. The java class works fine with the image provided by the tutorial, however when I change the image I get the following error...

java.lang.IllegalArgumentException: Tables must be 0, 1, 2, or 3.
      at sun.awt.image.codec.JPEGParam.setDCHuffmanComponentMapping(JPEGParam.java:589)
      at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
      at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(JPEGImageDecoderImpl.java:226)
      at com.sun.media.jai.codecimpl.JPEGImage.<init>(JPEGImageDecoder.java:112)
      at com.sun.media.jai.codecimpl.JPEGImageDecoder.decodeAsRenderedImage(JPEGImageDecoder.java:51)
      at com.sun.media.jai.opimage.CodecRIFUtil.create(CodecRIFUtil.java:89)
      at com.sun.media.jai.opimage.JPEGRIF.create(JPEGRIF.java:52)
      at java.lang.reflect.Method.invoke(Native Method)
      at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
      at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1669)
      at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
      at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
      at com.sun.media.jai.opimage.StreamRIF.create(StreamRIF.java:104)
      at java.lang.reflect.Method.invoke(Native Method)
      at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
      at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1669)
      at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
      at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
      at com.sun.media.jai.opimage.FileLoadRIF.create(FileLoadRIF.java:109)
      at java.lang.reflect.Method.invoke(Native Method)
      at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
      at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1669)
      at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
      at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
      at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:805)
      at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:853)
      at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2135)
      at kris.test.zoom.ImageDisplay.initialize(ImageDisplay.java:101)
      at kris.test.zoom.ImageDisplay.<init>(ImageDisplay.java:156)
      at kris.test.zoom.About.<init>(About.java:66)
      at kris.test.zoom.KeyFromImageMagnifier.<init>(KeyFromImageMagnifier.java:95)
      at java.lang.reflect.Constructor.newInstance(Native Method)
      at com.ibm.etools.jbcf.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:81)

I've traced the error back to the declaration of the image...

private About aboutPanel = new About("C:\\presc.jpg",
                                        Magnifier.DEFAULT_MAGNIFICATION);     // this doesn't work

private About aboutPanel = new About("C:\\JaiTutor\\images\\Pisa.jpg",          
                                       Magnifier.DEFAULT_MAGNIFICATION);           // this does work!!!

what's confusing is the fact that both images are JPEG images. I've heard that there are different types of JPEG image, if this is correct is there anyway of changing the code so all types of JPEG images are excepted?

I'd be very grateful to anyone who can shed some light onto this problem

Thanks
Kris
ASKER CERTIFIED SOLUTION
Avatar of B000GT
B000GT

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial