Hi,
Here is some documentation:
"The direct color model is a color model which specifies a translation
from
pixel values to alpha, red, green, and blue components using the actual
bits
of the pixel value. This color model is similar to an X11 TrueColor
visual."
"The Abstract Window Toolkit represents each pixel as a 32-bit integer.
Bits 24-31
are the alpha transparency, bits 16-23 are the red value, bits 8- 15 are
the green
value, and bits 0-7 are the blue value."
You can use lookup table to save space and generate colors on fly.
Jacob Nikom.
Eric Chao wrote:
>
> I have an image that I wanted to print... This image is constructed
> using MemoryImageSource using an array of bytes, with each byte
> representing a pixel.
> I also have a DirectColorModal to translate the color in each pixel.
>
> image = createImage
> (new MemoryImageSource
> (d.width,
> d.height,
> dcm, /* Direct Color
> Model */
> pixels, /* array of bytes
> */
> 0,
> d.width) );
>
> When I tried to print the image. I keep getting this error(listed
> below). But when I change the array of bytes to array of ints. It
> worked. But I do not want to store my data as ints when bytes works
> fine... So any ideas???
>
> Error Message:
> ============
> Exception occurred during event dispatching:
> java.lang.ClassCastException: java.awt.image.DirectColorModel
> at sun.awt.motif.PSGraphics.blitImage(Compiled Code)
> at sun.awt.motif.PSGraphics.drawImage(Compiled Code)
> at MyCanvas.paint(Compiled Code)
> at MemoryImageSourceTest1.actionPerformed(Compiled Code)
> at java.awt.Button.processActionEvent(Compiled Code)
> at java.awt.Button.processEvent(Compiled Code)
> at java.awt.Component.dispatchEventImpl(Compiled Code)
> at java.awt.Component.dispatchEvent(Compiled Code)
> at java.awt.EventDispatchThread.run(Compiled Code)
>
> Chang-Cheng (Eric) Chao
> Merlin Software Technologies Inc.
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]