Re: [AD] bug in getpixel

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Saturday 26 November 2005 01:37 pm, Grzegorz Adam Hankiewicz wrote:
> I don't understand the rationale behind adding just one byte. Say
> I wanted a bitmap of 3x1 pixels, which will malloc 3 * 1 * 3 =
> 9 bytes. Adding one makes it 10, but wouldn't alignment rules
> require 12?

Not really, since reading the first and second pixel would overread into the 
first byte of the second and third pixel (which would then be masked out). 
It's only the last pixel that needs the extra padding.

xxx xxx xxx
\___/          - first pixel read

xxx xxx xxx
    \___/      - second pixel read

xxx xxx xxx *
        \___/  - third pixel read

> How about 64bit machines?

As long as you only read 4 bytes (with uint32_t) that won't matter.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/