[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> >By the way, did you experience any problems when trying to load bitmaps?
I
> >posted a patch a couple of weeks ago replacing some longs with ints in
the
> >.bmp file reader, because the struct requires 32 bit integers in some
cases
> >where Allegro's code has longs. I assume that would be a nescessary
> >addition too, wouldn't it? Or is this in your patch too and did I simply
> >overlook it?
> >
> >
>
> I didn't notice any problems, but please repost the patch.
This is the relevant part of it. I haven't really tested this too much, and
mostly took the easy route of search&replace. I guess this, or something
like this, should be done for all filetypes Allegro can natively load.
Evert
Index: src/bmp.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/bmp.c,v
retrieving revision 1.15
diff -u -p -r1.15 bmp.c
--- src/bmp.c 11 Jan 2004 22:23:35 -0000 1.15
+++ src/bmp.c 6 Jan 2005 11:40:54 -0000
@@ -35,11 +35,11 @@
typedef struct BITMAPFILEHEADER
{
- unsigned long bfType;
- unsigned long bfSize;
+ unsigned int bfType;
+ unsigned int bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
- unsigned long bfOffBits;
+ unsigned int bfOffBits;
} BITMAPFILEHEADER;
@@ -48,25 +48,25 @@ typedef struct BITMAPFILEHEADER
*/
typedef struct BITMAPINFOHEADER
{
- unsigned long biWidth;
- unsigned long biHeight;
+ unsigned int biWidth;
+ unsigned int biHeight;
unsigned short biBitCount;
- unsigned long biCompression;
+ unsigned int biCompression;
} BITMAPINFOHEADER;
typedef struct WINBMPINFOHEADER /* size: 40 */
{
- unsigned long biWidth;
- unsigned long biHeight;
+ unsigned int biWidth;
+ unsigned int biHeight;
unsigned short biPlanes;
unsigned short biBitCount;
- unsigned long biCompression;
- unsigned long biSizeImage;
- unsigned long biXPelsPerMeter;
- unsigned long biYPelsPerMeter;
- unsigned long biClrUsed;
- unsigned long biClrImportant;
+ unsigned int biCompression;
+ unsigned int biSizeImage;
+ unsigned int biXPelsPerMeter;
+ unsigned int biYPelsPerMeter;
+ unsigned int biClrUsed;
+ unsigned int biClrImportant;
} WINBMPINFOHEADER;
@@ -173,7 +173,7 @@ static void read_bmicolors(int ncols, RG
static void read_1bit_line(int length, PACKFILE *f, BITMAP *bmp, int line)
{
unsigned char b[32];
- unsigned long n;
+ unsigned int n;
int i, j, k;
int pix;
@@ -199,7 +199,7 @@ static void read_1bit_line(int length, P
static void read_4bit_line(int length, PACKFILE *f, BITMAP *bmp, int line)
{
unsigned char b[8];
- unsigned long n;
+ unsigned int n;
int i, j, k;
int temp;
int pix;
@@ -229,7 +229,7 @@ static void read_4bit_line(int length, P
static void read_8bit_line(int length, PACKFILE *f, BITMAP *bmp, int line)
{
unsigned char b[4];
- unsigned long n;
+ unsigned int n;
int i, j, k;
int pix;
@@ -285,7 +285,7 @@ static void read_bitfields_image(PACKFIL
int bpp;
int bytes_per_pixel;
int red, grn, blu;
- unsigned long buffer;
+ unsigned int buffer;
bpp = bitmap_color_depth(bmp);
bytes_per_pixel = BYTES_PER_PIXEL(bpp);
@@ -523,7 +523,7 @@ BITMAP *load_bmp(AL_CONST char *filename
PALETTE tmppal;
int want_palette = TRUE;
int ncol;
- unsigned long biSize;
+ unsigned int biSize;
int bpp, dest_depth;
ASSERT(filename);
@@ -579,9 +579,9 @@ BITMAP *load_bmp(AL_CONST char *filename
bpp = 8;
if (infoheader.biCompression == BI_BITFIELDS) {
- unsigned long redMask = pack_igetl(f);
- unsigned long grnMask = pack_igetl(f);
- unsigned long bluMask = pack_igetl(f);
+ unsigned int redMask = pack_igetl(f);
+ unsigned int grnMask = pack_igetl(f);
+ unsigned int bluMask = pack_igetl(f);
if ((bluMask == 0x001f) && (redMask == 0x7C00))
bpp = 15;