dcsimg
Uncaught error on fetching image:
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Merlin_us
Posted On:   Tuesday, September 2, 2003 10:49 PM

I am developing an API for printing images. On starting of the application, my API will try to load the image. Some times it successfully loading the image. Some times it throws the following exception. Uncaught error fetching image: java.lang.ClassCastException at java.awt.image.ColorModel.getAlpha(ColorModel.java:814) at java.awt.image.ColorModel.getRGB(ColorModel.java:859) at sun.awt.image.ImageRepresentation.convertToRGB(ImageRepresentation.java:271) at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:485) at java.awt.image.AreaAveragingScaleFilter.accumPixels(AreaAveragingScaleFilter.java:196) at java.awt.image.AreaAveragingScaleFilter.   More>>


I am developing an API for printing images.
On starting of the application, my API will
try to load the image. Some times it successfully
loading the image. Some times it throws the following
exception.

Uncaught error fetching image:
java.lang.ClassCastException
at java.awt.image.ColorModel.getAlpha(ColorModel.java:814)
at java.awt.image.ColorModel.getRGB(ColorModel.java:859)
at sun.awt.image.ImageRepresentation.convertToRGB(ImageRepresentation.java:271)
at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:485)
at java.awt.image.AreaAveragingScaleFilter.accumPixels(AreaAveragingScaleFilter.java:196)
at java.awt.image.AreaAveragingScaleFilter.setPixels(AreaAveragingScaleFilter.java:235)
at sun.awt.image.PixelStore8.replayLines(PixelStore8.java:38)
at sun.awt.image.PixelStore.replay(PixelStore.java:217)
at sun.awt.image.PixelStore.replay(PixelStore.java:146)
at sun.awt.image.InputStreamImageSource.updateFromStore(InputStreamImageSource.java:295)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:244)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:168)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)





Since it is an Runtime exception, I am not
able to find which part of the code in my program is
wrong. I have tested the application with only one image.
Please give me some guide lines to solve this problem.
If you have a sample code please provide to me.

Thanks in advance.

   <<Less

Re: Uncaught error on fetching image:

Posted By:   Bahman_Barzideh  
Posted On:   Wednesday, September 3, 2003 04:37 AM

I took a look at the code for ColorModel. The error you
are getting seems to be caused by an incompatability between the image
you are trying to read and the transfer type that is passed
in/determined by ColorModel (i.e. it is being
told the data in the file can be read as an array of bytes and it find this
not to be the case). Since ColorModel is an abstract class,
I am sure you are not working with it directly. You must, however, be
passing a wrong parameter/option to the method(s) you use to load the
image. This is as much as I can figure based on the information you
have provided. I would suggest checking on two items. First, check
your code to see if you are telling the system what type of image is to
be loaded (jpeg, png, gif, etc). Second, make sure the file that contains
the image to be loaded has the correct suffix and is of a type that
Java can handle.



If tyese don't work, you might want to post the snipet of your code that
loads the picture.
About | Sitemap | Contact