Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

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.
0
InteractiveMind
Asked:
InteractiveMind
  • 5
  • 4
  • 2
  • +1
5 Solutions
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now