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.IllegalArgumentE xception: Tables must be 0, 1, 2, or 3.
at sun.awt.image.codec.JPEGPa ram.setDCH uffmanComp onentMappi ng(JPEGPar am.java:58 9)
at sun.awt.image.codec.JPEGIm ageDecoder Impl.readJ PEGStream( Native Method)
at sun.awt.image.codec.JPEGIm ageDecoder Impl.decod eAsBuffere dImage(JPE GImageDeco derImpl.ja va:226)
at com.sun.media.jai.codecimp l.JPEGImag e.<init>(J PEGImageDe coder.java :112)
at com.sun.media.jai.codecimp l.JPEGImag eDecoder.d ecodeAsRen deredImage (JPEGImage Decoder.ja va:51)
at com.sun.media.jai.opimage. CodecRIFUt il.create( CodecRIFUt il.java:89 )
at com.sun.media.jai.opimage. JPEGRIF.cr eate(JPEGR IF.java:52 )
at java.lang.reflect.Method.i nvoke(Nati ve Method)
at javax.media.jai.FactoryCac he.invoke( FactoryCac he.java:13 0)
at javax.media.jai.OperationR egistry.in vokeFactor y(Operatio nRegistry. java:1669)
at javax.media.jai.ThreadSafe OperationR egistry.in vokeFactor y(ThreadSa feOperatio nRegistry. java:481)
at javax.media.jai.registry.R IFRegistry .create(RI FRegistry. java:340)
at com.sun.media.jai.opimage. StreamRIF. create(Str eamRIF.jav a:104)
at java.lang.reflect.Method.i nvoke(Nati ve Method)
at javax.media.jai.FactoryCac he.invoke( FactoryCac he.java:13 0)
at javax.media.jai.OperationR egistry.in vokeFactor y(Operatio nRegistry. java:1669)
at javax.media.jai.ThreadSafe OperationR egistry.in vokeFactor y(ThreadSa feOperatio nRegistry. java:481)
at javax.media.jai.registry.R IFRegistry .create(RI FRegistry. java:340)
at com.sun.media.jai.opimage. FileLoadRI F.create(F ileLoadRIF .java:109)
at java.lang.reflect.Method.i nvoke(Nati ve Method)
at javax.media.jai.FactoryCac he.invoke( FactoryCac he.java:13 0)
at javax.media.jai.OperationR egistry.in vokeFactor y(Operatio nRegistry. java:1669)
at javax.media.jai.ThreadSafe OperationR egistry.in vokeFactor y(ThreadSa feOperatio nRegistry. java:481)
at javax.media.jai.registry.R IFRegistry .create(RI FRegistry. java:340)
at javax.media.jai.RenderedOp .createIns tance(Rend eredOp.jav a:805)
at javax.media.jai.RenderedOp .createRen dering(Ren deredOp.ja va:853)
at javax.media.jai.RenderedOp .getWidth( RenderedOp .java:2135 )
at kris.test.zoom.ImageDispla y.initiali ze(ImageDi splay.java :101)
at kris.test.zoom.ImageDispla y.<init>(I mageDispla y.java:156 )
at kris.test.zoom.About.<init >(About.ja va:66)
at kris.test.zoom.KeyFromImag eMagnifier .<init>(Ke yFromImage Magnifier. java:95)
at java.lang.reflect.Construc tor.newIns tance(Nati ve Method)
at com.ibm.etools.jbcf.vce.la uncher.rem otevm.Java BeansLaunc her.main(J avaBeansLa uncher.jav a:81)
I've traced the error back to the declaration of the image...
private About aboutPanel = new About("C:\\presc.jpg",
Magnifier.DEFAULT_MAGNIFIC ATION); // this doesn't work
private About aboutPanel = new About("C:\\JaiTutor\\image s\\Pisa.jp g",
Magnifier.DEFAULT_MAGNIFIC ATION); // 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
java.lang.IllegalArgumentE
at sun.awt.image.codec.JPEGPa
at sun.awt.image.codec.JPEGIm
at sun.awt.image.codec.JPEGIm
at com.sun.media.jai.codecimp
at com.sun.media.jai.codecimp
at com.sun.media.jai.opimage.
at com.sun.media.jai.opimage.
at java.lang.reflect.Method.i
at javax.media.jai.FactoryCac
at javax.media.jai.OperationR
at javax.media.jai.ThreadSafe
at javax.media.jai.registry.R
at com.sun.media.jai.opimage.
at java.lang.reflect.Method.i
at javax.media.jai.FactoryCac
at javax.media.jai.OperationR
at javax.media.jai.ThreadSafe
at javax.media.jai.registry.R
at com.sun.media.jai.opimage.
at java.lang.reflect.Method.i
at javax.media.jai.FactoryCac
at javax.media.jai.OperationR
at javax.media.jai.ThreadSafe
at javax.media.jai.registry.R
at javax.media.jai.RenderedOp
at javax.media.jai.RenderedOp
at javax.media.jai.RenderedOp
at kris.test.zoom.ImageDispla
at kris.test.zoom.ImageDispla
at kris.test.zoom.About.<init
at kris.test.zoom.KeyFromImag
at java.lang.reflect.Construc
at com.ibm.etools.jbcf.vce.la
I've traced the error back to the declaration of the image...
private About aboutPanel = new About("C:\\presc.jpg",
Magnifier.DEFAULT_MAGNIFIC
private About aboutPanel = new About("C:\\JaiTutor\\image
Magnifier.DEFAULT_MAGNIFIC
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.