Re: Color comparison
Re: Color comparison
- Subject: Re: Color comparison
- From: "Timothy J. Wood" <email@hidden>
- Date: Mon, 3 Jun 2002 20:30:58 -0700
On Monday, June 3, 2002, at 03:08 PM, David Sinclair wrote:
Is there an easier way of comparing them than getting the individual
color components (R, G, B) and seeing if the values are close?
Probably not.
Alternatively, is there any way of avoiding the difference in values. I
doubt this one is feasible, as it looks like a rounding difference --
e.g. 0.0588235 vs 0.0581305.
You could take the color you are going to compare against, archive it
an unarchive it to cause the same rounding. That's kind of silly though.
It's probably best to assume you pick a target color depth (i.e. 8
bits per channel or maybe 10, 12 or 16 if you want to plan for the
future) and see if the colors are within that tolerance of each other:
#define BITS_PER_CHANNEL (8)
if (rint(r1 * ((1<< BITS_PER_CHANNEL) -1)) == rint(r2 * ((1<<
BITS_PER_CHANNEL) -1)) && ...) {
colors will display the same on screen, so they are 'equal enough'
}
-tim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.