Skip to content

Commit

Permalink
improved rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Sep 1, 2024
1 parent d7cd68a commit a34d4a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions coders/bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,19 +1426,19 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
pixel|=(*p++) << 8;
red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
if (quantum_bits.red == 5)
red|=((red & 0xe000) >> 5);
red|=((red & 0xff000) >> 5);
if (quantum_bits.red <= 8)
red|=((red & 0xff00) >> 8);
green=((pixel & bmp_info.green_mask) << shift.green) >> 16;
if (quantum_bits.green == 5)
green|=((green & 0xe000) >> 5);
green|=((green & 0xff000) >> 5);
if (quantum_bits.green == 6)
green|=((green & 0xc000) >> 6);
green|=((green & 0xff00) >> 6);
if (quantum_bits.green <= 8)
green|=((green & 0xff00) >> 8);
blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;
if (quantum_bits.blue == 5)
blue|=((blue & 0xe000) >> 5);
blue|=((blue & 0xff000) >> 5);
if (quantum_bits.blue <= 8)
blue|=((blue & 0xff00) >> 8);
SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));
Expand Down

0 comments on commit a34d4a4

Please sign in to comment.