ColorModel

Can someone give me a quick run through of why you'd want to use the ColorModel class - and why it's useful ?

The MemoryImageSource class accepts a ColorModel as a parameter to one of it's constructors — what effect will this have?

Thanks.
LVL 25
InteractiveMindAsked:
Who is Participating?
 
objectsCommented:
It handles mapping pixel value into rgba colour components.
0
 
InteractiveMindAuthor Commented:
But what does that actually mean?
Are the pixels not stored in a way based on RGB ?  (a << 24)|(r << 16)|(g << 8)|(b)  [or something like that]
0
 
objectsCommented:
no they are merely stored as numbers. The ColorModel takes that value and returns the colour components.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
InteractiveMindAuthor Commented:
So, in the case of the MemoryImageSource: is there a default ColorModel that is used (if one is not specified) ?
0
 
objectsCommented:
Whats the data you're using, and how do you want it mapped?
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
http://www.java2s.com/ExampleCode/2D-Graphics-GUI/Color-Model.htm

oops i didn't knew you & objects wee in conversation.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> is there a default ColorModel that is used (if one is not specified) ?

Yes, it uses the default RGB colormodel.
0
 
InteractiveMindAuthor Commented:
I've got an IndexColorModel (produced using an algorithm I got elsewhere), which I pass to my MemoryImageSource constructor.

I then have an array called 'envMap' containing numbers ranging from 0-255. My rendering algorithm calculates which value to use (based on some unrelated criteria), and then passes that integer (from the envMap array) to the MemoryImageSource (or rather, sets the appropriate pixel within the pixel array to that integer).

So, the IndexColorModel in this case, would that just be using the given integer (from the envMap) to calculate the RGBA color to use?
0
 
objectsCommented:
Thats correct, using the map you specify.
Each index would correspond to a different rgb value

0
 
InteractiveMindAuthor Commented:
Okay, thanks very much.
0
 
objectsCommented:
no worries :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.