Yes, this can be reformulated easier as

i * 257 = i * 256 + i

and i / 256 will always be zero for i < 256.  Anyway, I suppose it
doesn't matter.  The question is what to do for mapping 16-bit back to
8-bit, when it wasn't necessarily originally produced from 8-bit.  I
suppose that dividing by 256 is the right thing to do, sorry about
that.  It just seemed strange to not do the inverse, but yeah, you're
right...

On Wed, Aug 26, 2009 at 5:21 PM, Nico Weber <tha...@chromium.org> wrote:
>> This code is incorrect, you should divide by 257, not 256.  See the
>> GDK_COLOR_RGB macro.
>
> That's not true. GDK_COLOR_RGB multiplies by 257 (= 0x10001) to
> distribute the bits evenly (
> http://www.mindcontrol.org/~hplus/graphics/expand-bits.html ). To get
> back, you can just shift (or, formulated differently, i == (i*257)/256
> for all i < 256).
>

--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to