[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
save_bmp produces BMP files in which a couple of the header fields are
wrong. The fix is attached.
See also: http://www.allegro.cc/forums/view_thread.php?_id=282709
--
王浩禎
--- bmp.c.old Tue Jul 15 13:40:36 2003
+++ bmp.c Tue Jul 15 13:37:08 2003
@@ -575,7 +575,7 @@
{
PACKFILE *f;
PALETTE tmppal;
- int bfSize;
+ int biSizeImage;
int depth;
int bpp;
int filler;
@@ -593,13 +593,13 @@
}
if (bpp == 8) {
- bfSize = 54 /* header */
- +256*4 /* palette */
- +bmp->w*bmp->h; /* image data */
+ biSizeImage = (256*4 /* palette */
+ +bmp->w*bmp->h /* image data */
+ +bmp->h*filler); /* filler */
}
else {
- bfSize = 54 /* header */
- +bmp->w*bmp->h*3; /* image data */
+ biSizeImage = (bmp->w*bmp->h*3 /* image data */
+ +bmp->h*filler); /* filler */
}
f = pack_fopen(filename, F_WRITE);
@@ -610,7 +610,7 @@
/* file_header */
pack_iputw(0x4D42, f); /* bfType ("BM") */
- pack_iputl(bfSize, f); /* bfSize */
+ pack_iputl(54 + biSizeImage, f); /* bfSize = header + biSizeImage */
pack_iputw(0, f); /* bfReserved1 */
pack_iputw(0, f); /* bfReserved2 */
@@ -620,15 +620,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 */