Re: [AD] Endianness in file routines

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


On 2003-03-14, Eric <ebotcazou@xxxxxxxxxx> wrote:
> > This reminds me, has anyone checked this?  It looks to me like the code
> > assumes little endianness.
> 
[snip]
> 
> Both functions looks ok to me.

You're right.  I didn't understand endianness concerns properly (well, I
did, but at some stage I made the mistake of listening to someone on
allegro.cc ;-)  Anyway, I checked out pack_igetw and pack_iputw on a big
endian machine.

> On the other hand, I've attached a patch that fixes an assumption of 
> little-endianess in src/bmp.c:read_24bit_line(). Does it seem correct to 
> you?
> 
> -- 
> Eric Botcazou
> --- /cvs/allegro/src/bmp.c	Wed Oct 16 14:02:38 2002
> +++ allegro/src/bmp.c	Mon Oct 28 11:23:44 2002
> @@ -262,9 +262,7 @@
>        c.b = pack_getc(f);
>        c.g = pack_getc(f);
>        c.r = pack_getc(f);
> -      bmp->line[line][i*3+_rgb_r_shift_24/8] = c.r;
> -      bmp->line[line][i*3+_rgb_g_shift_24/8] = c.g;
> -      bmp->line[line][i*3+_rgb_b_shift_24/8] = c.b;
> +      bmp_write24((unsigned long)bmp->line[line]+i*3, makecol24(c.r, c.g, c.b));
>        nbytes += 3;
>     }

Shouldn't the original code work too, assuming the shift variables are
set up properly?

-- 
王浩禎




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