Re: [AD] Extra byte in 24 bit bitmaps

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


Sven Sandberg <ssven@xxxxxxxxxx> writes:

> I need to read pixels in a 24 bit memory bitmap. It is then much faster to
> read 32 bits at a time and shift out the components than to read one byte
> three times (according to a test it's somewhat more than twice as fast on
> my P133). However, this will read one byte outside the allocated memory on
> the last pixel in the bitmap. Would it be possible to allocate one extra
> byte at the end of 24 bit bitmaps for this purpose? I attach a patch that
> does this. A better solution would of course be if someone could prove that
> it is harmless to read an extra unallocated byte on all platforms...

No, it is not harmless.  And reading pixels 32 bits at a time in 24
bpp modes is not portable.  Adding one byte to the end of bitmap is
only possible for memory bitmaps anyway.  If you want speed, you
should use 32 bpp for memory bitmaps and screen, instead of 24 bpp.

-- 
Michael Bukin



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