What's the difference, RGB vs Color [message #466412] |
Tue, 10 January 2006 07:33  |
Eclipse User |
|
|
|
SWT provides these 2 packages, I can not see the difference when using them.
org.eclipse.swt.graphics.Color
org.eclipse.swt.graphics.RGB
What are the differences of these 2 packages? And they should be used under
what conditions? Thanks
|
|
|
Re: What's the difference, RGB vs Color [message #466418 is a reply to message #466412] |
Tue, 10 January 2006 08:49   |
Eclipse User |
|
|
|
The Color is the actual object that will be used when rendering widgets. It has handles to operating system resources, and generally should be cached where possible using a map or similar. They must be dispose()d of after use (because they have OS resources).
An RGB, on the other hand, is merely a set of 3 numbers (red, green, blue values). It's used to specify a particular color (like 0,255,0 = blue; 255,0,0 = red etc.). You can create a Color object once you have an RGB value of what colour you want to use.
It's not necessary to create an RGB, because there's a constructor in Color that takes individual red, green and blue values. Whenever you obtain the RGB out of a Colour, it creates a new RGB instance to hold that data in, so one of the only reasons for having the RGB is that it is something that can be easily written to preferences files to denote what colour is required, and then to use it to obtain a Color instance when running.
Alex.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03089 seconds