GraphicsMagick: coders/bmp.c Populate upper byte to lower byte ...
GraphicsMagick Commits <[email protected]> Thu, 17 Aug 2023 02:58:15 -0500
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.10025.1692259104.8047.graphicsmagick-commit@lists.sourceforge.net> |
changeset 73f00b8d83ef in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=73f00b8d83ef summary: coders/bmp.c Populate upper byte to lower byte even for lower bpp than 8. diffstat: ChangeLog | 6 ++++++ coders/bmp.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diffs (65 lines): diff -r 7af1b1f1d506 -r 73f00b8d83ef ChangeLog --- a/ChangeLog Thu Aug 17 02:06:31 2023 +0200 +++ b/ChangeLog Thu Aug 17 09:57:52 2023 +0200 @@ -1,3 +1,9 @@ +2023-08-16 Fojtik Jaroslav <[email protected]> + + * coders/bmp.c Populate upper byte to lower byte even for lower + bpp than 8. It overcomes quantum scalling error in gm. Code should + be redesigned, but it is better than previous state. + 2023-08-17 Fojtik Jaroslav <[email protected]> * coders/bmp.c Enforce default matte for 40 byte header & 32bpp. diff -r 7af1b1f1d506 -r 73f00b8d83ef coders/bmp.c --- a/coders/bmp.c Thu Aug 17 02:06:31 2023 +0200 +++ b/coders/bmp.c Thu Aug 17 09:57:52 2023 +0200 @@ -1287,7 +1287,7 @@ } if ( bmp_info.bits_per_pixel == 32) { - image->matte = 1; + image->matte = True; bmp_info.alpha_mask=0xff000000U; bmp_info.red_mask=0x00ff0000U; bmp_info.green_mask=0x0000ff00U; @@ -1514,6 +1514,7 @@ } case 32: { + /* char ZeroOpacity = 1; */ /* Convert bitfield encoded DirectColor scanline. */ @@ -1537,18 +1538,19 @@ pixel|=((magick_uint32_t) *p++ << 16); pixel|=((magick_uint32_t) *p++ << 24); red=((pixel & bmp_info.red_mask) << shift.red) >> 16; - if (quantum_bits.red == 8) + if (quantum_bits.red <= 8) red|=(red >> 8); green=((pixel & bmp_info.green_mask) << shift.green) >> 16; - if (quantum_bits.green == 8) + if (quantum_bits.green <= 8) green|=(green >> 8); blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16; - if (quantum_bits.blue == 8) + if (quantum_bits.blue <= 8) blue|=(blue >> 8); if (image->matte != False) { opacity=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16; - if (quantum_bits.opacity == 8) + /* if(opacity!=0) ZeroOpacity=0; */ + if (quantum_bits.opacity <= 8) opacity|=(opacity >> 8); q->opacity=MaxRGB-ScaleShortToQuantum(opacity); } @@ -1570,6 +1572,7 @@ break; } } + /* if(ZeroOpacity) image->matte = False; */ break; } default: