summaryrefslogtreecommitdiff
path: root/tools/bmp2rb.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bmp2rb.c')
-rw-r--r--tools/bmp2rb.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c
index f7b92d0e6e..61c0268c49 100644
--- a/tools/bmp2rb.c
+++ b/tools/bmp2rb.c
@@ -49,21 +49,21 @@
49struct Fileheader 49struct Fileheader
50{ 50{
51 unsigned short Type; /* signature - 'BM' */ 51 unsigned short Type; /* signature - 'BM' */
52 unsigned long Size; /* file size in bytes */ 52 unsigned int Size; /* file size in bytes */
53 unsigned short Reserved1; /* 0 */ 53 unsigned short Reserved1; /* 0 */
54 unsigned short Reserved2; /* 0 */ 54 unsigned short Reserved2; /* 0 */
55 unsigned long OffBits; /* offset to bitmap */ 55 unsigned int OffBits; /* offset to bitmap */
56 unsigned long StructSize; /* size of this struct (40) */ 56 unsigned int StructSize; /* size of this struct (40) */
57 unsigned long Width; /* bmap width in pixels */ 57 unsigned int Width; /* bmap width in pixels */
58 unsigned long Height; /* bmap height in pixels */ 58 unsigned int Height; /* bmap height in pixels */
59 unsigned short Planes; /* num planes - always 1 */ 59 unsigned short Planes; /* num planes - always 1 */
60 unsigned short BitCount; /* bits per pixel */ 60 unsigned short BitCount; /* bits per pixel */
61 unsigned long Compression; /* compression flag */ 61 unsigned int Compression; /* compression flag */
62 unsigned long SizeImage; /* image size in bytes */ 62 unsigned int SizeImage; /* image size in bytes */
63 long XPelsPerMeter; /* horz resolution */ 63 int XPelsPerMeter; /* horz resolution */
64 long YPelsPerMeter; /* vert resolution */ 64 int YPelsPerMeter; /* vert resolution */
65 unsigned long ClrUsed; /* 0 -> color table size */ 65 unsigned int ClrUsed; /* 0 -> color table size */
66 unsigned long ClrImportant; /* important color count */ 66 unsigned int ClrImportant; /* important color count */
67} STRUCT_PACKED; 67} STRUCT_PACKED;
68 68
69struct RGBQUAD 69struct RGBQUAD
@@ -80,7 +80,7 @@ short readshort(void* value)
80 return bytes[0] | (bytes[1] << 8); 80 return bytes[0] | (bytes[1] << 8);
81} 81}
82 82
83int readlong(void* value) 83int readint(void* value)
84{ 84{
85 unsigned char* bytes = (unsigned char*) value; 85 unsigned char* bytes = (unsigned char*) value;
86 return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); 86 return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);
@@ -101,8 +101,8 @@ unsigned char brightness(struct RGBQUAD color)
101 ***************************************************************************/ 101 ***************************************************************************/
102 102
103int read_bmp_file(char* filename, 103int read_bmp_file(char* filename,
104 long *get_width, /* in pixels */ 104 int *get_width, /* in pixels */
105 long *get_height, /* in pixels */ 105 int *get_height, /* in pixels */
106 struct RGBQUAD **bitmap) 106 struct RGBQUAD **bitmap)
107{ 107{
108 struct Fileheader fh; 108 struct Fileheader fh;
@@ -111,11 +111,11 @@ int read_bmp_file(char* filename,
111 int fd = open(filename, O_RDONLY); 111 int fd = open(filename, O_RDONLY);
112 unsigned short data; 112 unsigned short data;
113 unsigned char *bmp; 113 unsigned char *bmp;
114 long width, height; 114 int width, height;
115 long padded_width; 115 int padded_width;
116 long size; 116 int size;
117 long row, col, i; 117 int row, col, i;
118 long numcolors, compression; 118 int numcolors, compression;
119 int depth; 119 int depth;
120 120
121 if (fd == -1) 121 if (fd == -1)
@@ -131,7 +131,7 @@ int read_bmp_file(char* filename,
131 return 2; 131 return 2;
132 } 132 }
133 133
134 compression = readlong(&fh.Compression); 134 compression = readint(&fh.Compression);
135 135
136 if (compression != 0) 136 if (compression != 0)
137 { 137 {
@@ -144,7 +144,7 @@ int read_bmp_file(char* filename,
144 144
145 if (depth <= 8) 145 if (depth <= 8)
146 { 146 {
147 numcolors = readlong(&fh.ClrUsed); 147 numcolors = readint(&fh.ClrUsed);
148 if (numcolors == 0) 148 if (numcolors == 0)
149 numcolors = 1 << depth; 149 numcolors = 1 << depth;
150 150
@@ -157,8 +157,8 @@ int read_bmp_file(char* filename,
157 } 157 }
158 } 158 }
159 159
160 width = readlong(&fh.Width); 160 width = readint(&fh.Width);
161 height = readlong(&fh.Height); 161 height = readint(&fh.Height);
162 padded_width = (width * depth / 8 + 3) & ~3; /* aligned 4-bytes boundaries */ 162 padded_width = (width * depth / 8 + 3) & ~3; /* aligned 4-bytes boundaries */
163 163
164 size = padded_width * height; /* read this many bytes */ 164 size = padded_width * height; /* read this many bytes */
@@ -172,13 +172,13 @@ int read_bmp_file(char* filename,
172 return 5; 172 return 5;
173 } 173 }
174 174
175 if (lseek(fd, (off_t)readlong(&fh.OffBits), SEEK_SET) < 0) 175 if (lseek(fd, (off_t)readint(&fh.OffBits), SEEK_SET) < 0)
176 { 176 {
177 debugf("error - Can't seek to start of image data\n"); 177 debugf("error - Can't seek to start of image data\n");
178 close(fd); 178 close(fd);
179 return 6; 179 return 6;
180 } 180 }
181 if (read(fd, (unsigned char*)bmp, (long)size) != size) 181 if (read(fd, (unsigned char*)bmp, (int)size) != size)
182 { 182 {
183 debugf("error - Can't read image\n"); 183 debugf("error - Can't read image\n");
184 close(fd); 184 close(fd);
@@ -276,12 +276,12 @@ int read_bmp_file(char* filename,
276 * destination formats 276 * destination formats
277 ****************************************************************************/ 277 ****************************************************************************/
278 278
279int transform_bitmap(const struct RGBQUAD *src, long width, long height, 279int transform_bitmap(const struct RGBQUAD *src, int width, int height,
280 int format, unsigned short **dest, long *dst_width, 280 int format, unsigned short **dest, int *dst_width,
281 long *dst_height) 281 int *dst_height)
282{ 282{
283 long row, col; 283 int row, col;
284 long dst_w, dst_h; 284 int dst_w, dst_h;
285 285
286 switch (format) 286 switch (format)
287 { 287 {
@@ -395,12 +395,12 @@ int transform_bitmap(const struct RGBQUAD *src, long width, long height,
395 * some #define's 395 * some #define's
396 ****************************************************************************/ 396 ****************************************************************************/
397 397
398void generate_c_source(char *id, long width, long height, 398void generate_c_source(char *id, int width, int height,
399 const unsigned short *t_bitmap, long t_width, 399 const unsigned short *t_bitmap, int t_width,
400 long t_height, int format) 400 int t_height, int format)
401{ 401{
402 FILE *f; 402 FILE *f;
403 long i, a; 403 int i, a;
404 404
405 f = stdout; 405 f = stdout;
406 406
@@ -439,10 +439,10 @@ void generate_c_source(char *id, long width, long height,
439 * Outputs an ascii picture of the bitmap 439 * Outputs an ascii picture of the bitmap
440 ****************************************************************************/ 440 ****************************************************************************/
441 441
442void generate_ascii(long width, long height, struct RGBQUAD *bitmap) 442void generate_ascii(int width, int height, struct RGBQUAD *bitmap)
443{ 443{
444 FILE *f; 444 FILE *f;
445 long x, y; 445 int x, y;
446 446
447 f = stdout; 447 f = stdout;
448 448
@@ -482,8 +482,8 @@ int main(int argc, char **argv)
482 int format = 0; 482 int format = 0;
483 struct RGBQUAD *bitmap = NULL; 483 struct RGBQUAD *bitmap = NULL;
484 unsigned short *t_bitmap = NULL; 484 unsigned short *t_bitmap = NULL;
485 long width, height; 485 int width, height;
486 long t_width, t_height; 486 int t_width, t_height;
487 487
488 488
489 for (i = 1;i < argc;i++) 489 for (i = 1;i < argc;i++)