}
public MemoryImageSource getImageSource()
{
ColorModel cm;
MemoryImageSource mis;
if (noOfEntries > 0)
{
// There is a color palette; create an IndexColorModel
cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b);
}
else
{
// There is no palette; use the default RGB color model
cm = ColorModel.getRGBdefault();
}
// Create MemoryImageSource
if (bitsPerPixel > 8)
{
// use one int per pixel
mis = new MemoryImageSource(width, height, cm, intData, 0, width);
}
else
{
// use one byte per pixel
mis = new MemoryImageSource(width, height, cm, byteData, 0, width);
}
return mis; // this can be used by JComponent.createImage()
}