K, here is some better math for getRGB, performance will probably be
important:

    return [c>>>16, c>>8&~0xFF00, c&~0xFFFFF00];

You can also try using the ColorTransform or Color class to get the rgb
values, except they might be slower than getting the raw math right.

M.

On 3/15/06, Josh Buhler <[EMAIL PROTECTED]> wrote:
>
> Thanks - I'll give it a shot and see how it goes.
>
>
> - Josh
>
> On Mar 15, 2006, at 3:10 PM, elibol wrote:
>
> > I tried comparing the hex values directly, but there were
> > inaccuracies,
> > maybe the same ones you've been having. I think since the value of a
> > particular color precedes with a 0 even when it's below 17(0F), the
> > preceding 0 causes a shifting in the comparison. It would, for
> > example,
> > cause 0x000000 to seem farther to 0x123456 than 0x00FF00, where
> > visually you
> > can see clearly that black is closer to 0x000000.
> >
> > btw in my example, var a = 0x12345 where it should be 0x123456.
> >
> > The numbers hold to be accurate after correcting this typo.
> >
> > On 3/15/06, Josh Buhler <[EMAIL PROTECTED]> wrote:
> >>
> >> I'm working on a project that requires that I take an uploaded image,
> >> and convert it to use a limited palette of colors - around 5-10
> >> colors.
> >>
> >> I've got the custom palette I have to work with stored in an array,
> >> and for each color in my image, I've got it finding the color in the
> >> array it's closest to numerically, but the results aren't exactly
> >> what I'm looking for.
> >>
> >> Does anybody know of any formulas available for comparing multiple
> >> colors and finding the ones that are the closest matches? I've been
> >> searching Google for a while, with no luck. Any good resources on
> >> color formulas & such would be appreciated.
> >>
> >> - Josh
> >> _______________________________________________
> >> [email protected]
> >> To change your subscription options or search the archive:
> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >>
> >> Brought to you by Fig Leaf Software
> >> Premier Authorized Adobe Consulting and Training
> >> http://www.figleaf.com
> >> http://training.figleaf.com
> >>
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
>
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to