Skip to content

Commit fe8e0bf

Browse files
hughbeakoeplinger
authored andcommitted
Refactor bmpcodec (mono#511)
Aims: - Make it simpler to read this 1000 line long function - Make it clearer what we're doing There are a number of discrete stages involved in decoding a bmp image - Reading the header - Reading the palette if any - Calculating the stride - Reading the scans - Converting the scans to a target pixel format if necessary This PR splits the core bmp decoding into several routines that clarify these stages and will make it easier for me to make future changes
1 parent 9adf0e2 commit fe8e0bf

File tree

6 files changed

+282
-264
lines changed

6 files changed

+282
-264
lines changed

src/bitmap-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ typedef struct {
7777
unsigned intwidth;
7878
unsigned intheight;
7979
intstride;
80-
intpixel_format;
80+
PixelFormatpixel_format;
8181
BYTE *scan0;
8282
UINT_PTRreserved;
8383
/* the rest of the structure isn't part of MS GDI+ definition */

src/bitmap.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,16 +2097,12 @@ GdipBitmapGetPixel (GpBitmap *bitmap, INT x, INT y, ARGB *color)
20972097
break;
20982098
}
20992099
case PixelFormat16bppARGB1555:
2100-
case PixelFormat16bppRGB555: {
2101-
WORD *scan = (WORD *) v;
2102-
*color = gdip_convert_16bppRGB555_ToARGB (scan[x]);
2100+
case PixelFormat16bppRGB555:
2101+
*color = gdip_getpixel_16bppRGB555 (v, x);
21032102
break;
2104-
}
2105-
case PixelFormat16bppRGB565: {
2106-
WORD *scan = (WORD *) v;
2107-
*color = gdip_convert_16bppRGB565_ToARGB (scan[x]);
2103+
case PixelFormat16bppRGB565:
2104+
*color = gdip_getpixel_16bppRGB565 (v, x);
21082105
break;
2109-
}
21102106
default:
21112107
return NotImplemented;
21122108
}

0 commit comments

Comments
 (0)