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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
It handles mapping pixel value into rgba colour components.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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]
Mick BarryJava DeveloperCommented:
no they are merely stored as numbers. The ColorModel takes that value and returns the colour components.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

InteractiveMindAuthor Commented:
So, in the case of the MemoryImageSource: is there a default ColorModel that is used (if one is not specified) ?
Mick BarryJava DeveloperCommented:
Whats the data you're using, and how do you want it mapped?
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
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.
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.
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?
Mick BarryJava DeveloperCommented:
Thats correct, using the map you specify.
Each index would correspond to a different rgb value

InteractiveMindAuthor Commented:
Okay, thanks very much.
Mick BarryJava DeveloperCommented:
no worries :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.