(rbmp_encode.c) Make it C89-friendly

This commit is contained in:
twinaphex 2015-09-21 11:58:36 +02:00
parent b9ba75403e
commit 4c2bc0c1fe

View File

@ -31,44 +31,79 @@ static bool write_header_bmp(RFILE *file, unsigned width, unsigned height)
unsigned line_size = (width * 3 + 3) & ~3; unsigned line_size = (width * 3 + 3) & ~3;
unsigned size = line_size * height + 54; unsigned size = line_size * height + 54;
unsigned size_array = line_size * height; unsigned size_array = line_size * height;
uint8_t header[54];
/* Generic BMP stuff. */ /* Generic BMP stuff. */
const uint8_t header[] = {
/* signature */ /* signature */
'B', 'M', header[0] = 'B';
/* file size */ header[1] = 'M';
(uint8_t)(size >> 0), (uint8_t)(size >> 8), /* file size */
(uint8_t)(size >> 16), (uint8_t)(size >> 24), header[2] = (uint8_t)(size >> 0);
/* reserved */ header[3] = (uint8_t)(size >> 8);
0, 0, 0, 0, header[4] = (uint8_t)(size >> 16);
/* offset */ header[5] = (uint8_t)(size >> 24);
54, 0, 0, 0, /* reserved */
/* DIB size */ header[6] = 0;
40, 0, 0, 0, header[7] = 0;
/* width */ header[8] = 0;
(uint8_t)(width >> 0), (uint8_t)(width >> 8), header[9] = 0;
(uint8_t)(width >> 16), (uint8_t)(width >> 24), /* offset */
/* height */ header[10] = 54;
(uint8_t)(height >> 0), (uint8_t)(height >> 8), header[11] = 0;
(uint8_t)(height >> 16), (uint8_t)(height >> 24), header[12] = 0;
/* color planes */ header[13] = 0;
1, 0, /* DIB size */
/* bits per pixel */ header[14] = 40;
24, 0, header[15] = 0;
/* compression method */ header[16] = 0;
0, 0, 0, 0, header[17] = 0;
/* image data size */ /* Width */
(uint8_t)(size_array >> 0), (uint8_t)(size_array >> 8), header[18] = (uint8_t)(width >> 0);
(uint8_t)(size_array >> 16), (uint8_t)(size_array >> 24), header[19] = (uint8_t)(width >> 8);
/* horizontal resolution */ header[20] = (uint8_t)(width >> 16);
19, 11, 0, 0, header[21] = (uint8_t)(width >> 24);
/* vertical resolution */ /* Height */
19, 11, 0, 0, header[22] = (uint8_t)(height >> 0);
/* palette size */ header[23] = (uint8_t)(height >> 8);
0, 0, 0, 0, header[24] = (uint8_t)(height >> 16);
/* important color count */ header[25] = (uint8_t)(height >> 24);
0, 0, 0, 0 /* Color planes */
}; header[26] = 1;
header[27] = 0;
/* Bits per pixel */
header[28] = 24;
header[29] = 0;
/* Compression method */
header[30] = 0;
header[31] = 0;
header[32] = 0;
header[33] = 0;
/* Image data size */
header[34] = (uint8_t)(size_array >> 0);
header[35] = (uint8_t)(size_array >> 8);
header[36] = (uint8_t)(size_array >> 16);
header[37] = (uint8_t)(size_array >> 24);
/* Horizontal resolution */
header[38] = 19;
header[39] = 11;
header[40] = 0;
header[41] = 0;
/* Vertical resolution */
header[42] = 19;
header[43] = 11;
header[44] = 0;
header[45] = 0;
/* Palette size */
header[46] = 0;
header[47] = 0;
header[48] = 0;
header[49] = 0;
/* Important color count */
header[50] = 0;
header[51] = 0;
header[52] = 0;
header[53] = 0;
return retro_fwrite(file, header, sizeof(header)) == sizeof(header); return retro_fwrite(file, header, sizeof(header)) == sizeof(header);
} }