[3341] in java-interest
Re: default ColorModel?
daemon@ATHENA.MIT.EDU (Jim Graham)
Wed Nov 8 04:56:17 1995
Date: Tue, 7 Nov 1995 23:56:09 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: dgourley@CS.Berkeley.EDU, java-interest@java.Eng.Sun.COM
Hi David,
> > > I cant seem to find it, does anyone know what the default ColorModel
> > > is for awt Components(eg. Frames)? Thanks a lot.
> >
> > See Component.getColorModel().
>
> Yes, but is the default a DirectColorModel or an IndexColorModel. I am
> constructing my frames via an external library, even tho I am not able to
> tell yet how my palette is doing, I can forsee problems in this in the
> future.
I couldn't possibly tell you - it depends on the characteristics of the
display of the user who is running your Applet. You have to execute
Component.getColorModel() at runtime and adapt to it.
The basic correlations is that if you are running on anything less than
8 bits deep you will probably get an IndexColorModel, but if you are
running on a deeper display you will probably get a DirectColorModel.
But, don't count on that you may get some "FoobarColorModel" if there
is a screen that doesn't match these two common color spaces. Any
subclass of ColorModel can be returned by that method, Index and Direct
are just the two most common mechanisms for specifying color...
In any case, while it may be useful to know the color model of the
underlying screen for optimizations under some circumstances, you can
always invent your own color model, report pixels in that color model,
and the image display code will adapt itself to your color model. If
you recognize the ColorModel you get, you can generate pixels in that
space and the underlying code should work faster, but if you don't
recognize it, then just pick one of your own that you are comfortable
working in. That is why the ImageConsumer.setPixels methods take a
ColorModel argument. Currently the image code doesn't have any
optimizations to take advantage of noticing if you are reporting
pixels in the default ColorModel, but the APIs are in place for adding
that optimization in the future (hopefully by 1.0 Final).
...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com