diff --git a/ext/gd/libgd/bmp.h b/ext/gd/libgd/bmp.h index cecde0383f53..4367c36d043b 100644 --- a/ext/gd/libgd/bmp.h +++ b/ext/gd/libgd/bmp.h @@ -28,6 +28,7 @@ extern "C" { #define BMP_WINDOWS_V3 40 #define BMP_OS2_V1 12 #define BMP_OS2_V2 64 +#define BMP_WINDOWS_V3INFO 56 #define BMP_WINDOWS_V4 108 #define BMP_WINDOWS_V5 124 diff --git a/ext/gd/libgd/gd_bmp.c b/ext/gd/libgd/gd_bmp.c index 00903d5ff8dc..4d193c3a1113 100644 --- a/ext/gd/libgd/gd_bmp.c +++ b/ext/gd/libgd/gd_bmp.c @@ -545,6 +545,7 @@ static int bmp_read_info(gdIOCtx *infile, bmp_info_t *info) switch (info->len) { /* For now treat Windows v4 + v5 as v3 */ case BMP_WINDOWS_V3: + case BMP_WINDOWS_V3INFO: case BMP_WINDOWS_V4: case BMP_WINDOWS_V5: BMP_DEBUG(printf("Reading Windows Header\n")); @@ -685,8 +686,12 @@ static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, b BMP_DEBUG(printf("Bitfield compression isn't supported for 24-bit\n")); return 1; } - BMP_DEBUG(printf("Currently no bitfield support\n")); - return 1; + /* For 32 BPP images, the bitfields do not contain any useful information. They can be safely skipped. */ + if (info->depth != 32) { + BMP_DEBUG(printf("Currently no bitfield support\n")); + return 1; + } + break; case BMP_BI_RLE8: diff --git a/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-input.bmp b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-input.bmp new file mode 100644 index 000000000000..994f35a96ead Binary files /dev/null and b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-input.bmp differ diff --git a/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-output.png b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-output.png new file mode 100644 index 000000000000..e3d27ee538de Binary files /dev/null and b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027-output.png differ diff --git a/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027.phpt b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027.phpt new file mode 100644 index 000000000000..5f9762b2034a --- /dev/null +++ b/ext/gd/tests/imagecreatefrombmp-v3info-32bpp-bitfields-11027.phpt @@ -0,0 +1,18 @@ +--TEST-- +imagecreatefrombmp() - test image with BITMAPV3INFOHEADER, 32bpp and (unnecessary) bitfields +--EXTENSIONS-- +gd +--SKIPIF-- + +--FILE-- + +--EXPECT-- +The images are equal. diff --git a/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027-input.bmp b/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027-input.bmp new file mode 100644 index 000000000000..1332fc4c93cb Binary files /dev/null and b/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027-input.bmp differ diff --git a/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027.phpt b/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027.phpt new file mode 100644 index 000000000000..4bc97e1bf51b --- /dev/null +++ b/ext/gd/tests/imagecreatefrombmp-v5-32bpp-bitfields-11027.phpt @@ -0,0 +1,18 @@ +--TEST-- +imagecreatefrombmp() - test image with BITMAPV5HEADER, 32bpp and (unnecessary) bitfields +--EXTENSIONS-- +gd +--SKIPIF-- + +--FILE-- + +--EXPECT-- +The images are equal.