Name: dk106046 Date: 10/14/2003
The problem is best described on this forum entry:
http://forum.java.sun.com/thread.jsp?forum=4&thread=289012
The customer is loading an 8 bit image, the ImageFetcher starts , and is working on the image, it goes into PixelStore, and then PixelStore8, where it calls replayLines
The lines are replayed, and we find that the AreaAveragingScaleFilter is working with an ImageRepresentation containing an Indexed color model, and a byte array, so it
all works fine.
We can see in accumPixels that the test is made to see if the array is bytes or ints, and the right RGB values are found. At the bottom of the loop, where dyrem becomes
zero, computeRow is called to get an INT array, and the corresponding setPixels for an int array is called, passing the default RGB colormodel, and the int array.
At this point, in setPixels, the internal color model is still Indexed, so a convert to RGB is required. The internal byte array biRaster is replaced by an int array, and
each item is computed using getRGB with the indexedColorModel, so again we are all fine.
Now what happens next is not fine. We have now converted to DirectColorModel, and the array is ints, but the next time through accumPixels, the model is set back to
an IndexedColorModel, but the int array remains.
setPixels of int is called, and it recognises the IndexedColorModel, so calls converttoRGB, which tries to use the color model with each element of the biRaster, but thats
an int array, so it throws a ClassCastException:
java.lang.ClassCastException: java.lang.Object
at java.awt.image.ColorModel.getAlpha(ColorModel.java:856)
at java.awt.image.ColorModel.getRGB(ColorModel.java:901)
at sun.awt.image.ImageRepresentation.convertToRGB(ImageRepresentation.java:312)
at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:527)
at java.awt.image.AreaAveragingScaleFilter.accumPixels(AreaAveragingScaleFilter.java:229)
at java.awt.image.AreaAveragingScaleFilter.setPixels(AreaAveragingScaleFilter.java:268)
at sun.awt.image.PixelStore8.replayLines(PixelStore8.java:69)
at sun.awt.image.PixelStore.replay(PixelStore.java:248)
at sun.awt.image.PixelStore.replay(PixelStore.java:177)
at sun.awt.image.InputStreamImageSource.updateFromStore(InputStreamImageSource.java:334)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:283)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:173)
======================================================================