[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2003-07-15, Eric <ebotcazou@xxxxxxxxxx> wrote:
> > save_bmp produces BMP files in which a couple of the header fields are
> > wrong. The fix is attached.
>
> Weird that it wasn't spotted earlier.
I guess most loaders don't care about those fields.
> So the size of the palette must be
> included in the biSizeImage field in 8bpp mode?
Umm... oops. I wonder how that slipped through. Thanks for spotting
it. Attached a different patch.
This time I checked the md5sums of save_bmp's output against GIMP
output. I needed to manually patch the dots-per-metre fields of
save_bmp's output for the md5sums to be the same, but that's all.
Maybe we should fill in the dots-per-metre fields too? Putting zeros in
those fields looks to be non-standard.
--
王浩禎
--- bmp.c.old Tue Jul 15 13:40:36 2003
+++ bmp.c Wed Jul 16 12:47:28 2003
@@ -576,6 +576,7 @@
PACKFILE *f;
PALETTE tmppal;
int bfSize;
+ int biSizeImage;
int depth;
int bpp;
int filler;
@@ -593,13 +594,14 @@
}
if (bpp == 8) {
- bfSize = 54 /* header */
- +256*4 /* palette */
- +bmp->w*bmp->h; /* image data */
+ biSizeImage = (bmp->w + filler) * bmp->h;
+ bfSize = (54 /* header */
+ + 256*4 /* palette */
+ + biSizeImage); /* image data */
}
else {
- bfSize = 54 /* header */
- +bmp->w*bmp->h*3; /* image data */
+ biSizeImage = (bmp->w*3 + filler) * bmp->h;
+ bfSize = 54 + biSizeImage; /* header + image data */
}
f = pack_fopen(filename, F_WRITE);
@@ -620,15 +622,13 @@
pack_iputl(54, f);
/* info_header */
- bfSize = bmp->w * bmp->h * bpp/8;
-
pack_iputl(40, f); /* biSize */
pack_iputl(bmp->w, f); /* biWidth */
pack_iputl(bmp->h, f); /* biHeight */
pack_iputw(1, f); /* biPlanes */
pack_iputw(bpp, f); /* biBitCount */
pack_iputl(0, f); /* biCompression */
- pack_iputl(bfSize, f); /* biSizeImage */
+ pack_iputl(biSizeImage, f); /* biSizeImage */
pack_iputl(0, f); /* biXPelsPerMeter */
pack_iputl(0, f); /* biYPelsPerMeter */