diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-09-04 20:49:11 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-09-04 20:49:11 +0000 |
commit | 7a22ba36cb7a9028eea35be269c5a825d97e4e14 (patch) | |
tree | 217d0d3b7cd19266e3c596e46ef30100d81debf0 /tools | |
parent | 5420c3f67225f6233fe9252e3b5d44da4d4fa217 (diff) | |
download | rockbox-7a22ba36cb7a9028eea35be269c5a825d97e4e14.tar.gz rockbox-7a22ba36cb7a9028eea35be269c5a825d97e4e14.zip |
Make bdf2bmp work on 64 bit hosts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18416 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bdf2bmp.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/tools/bdf2bmp.c b/tools/bdf2bmp.c index 8ca73cd49f..5422a65e99 100644 --- a/tools/bdf2bmp.c +++ b/tools/bdf2bmp.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <sys/stat.h> /* stat() */ | 53 | #include <sys/stat.h> /* stat() */ |
54 | #include <sys/types.h> /* stat ? */ | 54 | #include <sys/types.h> /* stat ? */ |
55 | #include <ctype.h> /* isdigit() */ | 55 | #include <ctype.h> /* isdigit() */ |
56 | #include <stdint.h> /* int types */ | ||
56 | 57 | ||
57 | #define LINE_CHARMAX 1000 /* number of max characters in bdf-font-file; number is without reason */ | 58 | #define LINE_CHARMAX 1000 /* number of max characters in bdf-font-file; number is without reason */ |
58 | #define FILENAME_CHARMAX 256 /* number of max characters in filenames; number is without reason */ | 59 | #define FILENAME_CHARMAX 256 /* number of max characters in filenames; number is without reason */ |
@@ -109,10 +110,10 @@ int main(int argc, char *argv[]); | |||
109 | * LSB .. Least Significant Byte first (LittleEndian) e.g. Intel Pentium | 110 | * LSB .. Least Significant Byte first (LittleEndian) e.g. Intel Pentium |
110 | */ | 111 | */ |
111 | void checkEndian(void){ | 112 | void checkEndian(void){ |
112 | unsigned long ulong = 0x12345678; | 113 | uint32_t uint32 = 0x12345678; |
113 | unsigned char *ucharP; | 114 | unsigned char *ucharP; |
114 | 115 | ||
115 | ucharP = (unsigned char *)(&ulong); | 116 | ucharP = (unsigned char *)(&uint32); |
116 | if(*ucharP == 0x78){ | 117 | if(*ucharP == 0x78){ |
117 | d_printf("LSB 0x%x\n", *ucharP); | 118 | d_printf("LSB 0x%x\n", *ucharP); |
118 | endian = 1; | 119 | endian = 1; |
@@ -166,9 +167,9 @@ void writeBmpFile(unsigned char *bitmapP, int spacing, int colchar, FILE *bmpP){ | |||
166 | int bmppad; /* number of padding pixels */ | 167 | int bmppad; /* number of padding pixels */ |
167 | unsigned long bmpTotalSize; /* bmp filesize (byte) */ | 168 | unsigned long bmpTotalSize; /* bmp filesize (byte) */ |
168 | /* bmp-lines needs to be long alined and padded with 0 */ | 169 | /* bmp-lines needs to be long alined and padded with 0 */ |
169 | unsigned long ulong; | 170 | uint32_t uint32; |
170 | unsigned short ushort; | 171 | uint16_t uint16; |
171 | signed long slong; | 172 | int32_t sint32; |
172 | unsigned char uchar; | 173 | unsigned char uchar; |
173 | int i,x,y,g,tmp; | 174 | int i,x,y,g,tmp; |
174 | int rowchar; /* number of row glyphs */ | 175 | int rowchar; /* number of row glyphs */ |
@@ -188,51 +189,51 @@ void writeBmpFile(unsigned char *bitmapP, int spacing, int colchar, FILE *bmpP){ | |||
188 | 189 | ||
189 | bmppad = ((bmpw + 3) / 4 * 4) - bmpw; | 190 | bmppad = ((bmpw + 3) / 4 * 4) - bmpw; |
190 | bmpTotalSize = (bmpw + bmppad) * bmph | 191 | bmpTotalSize = (bmpw + bmppad) * bmph |
191 | + sizeof(long)*11 + sizeof(short)*5 + sizeof(char)*4*256; | 192 | + sizeof(int32_t)*11 + sizeof(int16_t)*5 + sizeof(char)*4*256; |
192 | v_printf(" BMP filesize = %d bytes\n", (int)bmpTotalSize); | 193 | v_printf(" BMP filesize = %d bytes\n", (int)bmpTotalSize); |
193 | 194 | ||
194 | 195 | ||
195 | /* | 196 | /* |
196 | * BITMAPFILEHEADER struct | 197 | * BITMAPFILEHEADER struct |
197 | */ | 198 | */ |
198 | ushort = 0x4d42; /* 4d = 'M', 42 = 'B' */ | 199 | uint16 = 0x4d42; /* 4d = 'M', 42 = 'B' */ |
199 | dwrite(&ushort, sizeof(ushort), bmpP); | 200 | dwrite(&uint16, sizeof(uint16), bmpP); |
200 | ulong = bmpTotalSize; | 201 | uint32 = bmpTotalSize; |
201 | dwrite(&ulong, sizeof(ulong), bmpP); | 202 | dwrite(&uint32, sizeof(uint32), bmpP); |
202 | ushort = 0x00; | 203 | uint16 = 0x00; |
203 | dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */ | 204 | dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */ |
204 | dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */ | 205 | dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */ |
205 | 206 | ||
206 | /* bfOffBits: offset to image-data array */ | 207 | /* bfOffBits: offset to image-data array */ |
207 | ulong = sizeof(long)*11 + sizeof(short)*5 + sizeof(char)*4*256; | 208 | uint32 = sizeof(int32_t)*11 + sizeof(int16_t)*5 + sizeof(char)*4*256; |
208 | dwrite(&ulong, sizeof(ulong), bmpP); | 209 | dwrite(&uint32, sizeof(uint32), bmpP); |
209 | 210 | ||
210 | 211 | ||
211 | /* | 212 | /* |
212 | * BITMAPINFOHEADER struct | 213 | * BITMAPINFOHEADER struct |
213 | */ | 214 | */ |
214 | ulong = 40; /* when Windows-BMP, this is 40 */ | 215 | uint32 = 40; /* when Windows-BMP, this is 40 */ |
215 | dwrite(&ulong, sizeof(ulong), bmpP); | 216 | dwrite(&uint32, sizeof(uint32), bmpP); |
216 | slong = bmpw; /* biWidth */ | 217 | sint32 = bmpw; /* biWidth */ |
217 | dwrite(&slong, sizeof(slong), bmpP); | 218 | dwrite(&sint32, sizeof(sint32), bmpP); |
218 | slong = bmph; /* biHeight: down-top */ | 219 | sint32 = bmph; /* biHeight: down-top */ |
219 | dwrite(&slong, sizeof(slong), bmpP); | 220 | dwrite(&sint32, sizeof(sint32), bmpP); |
220 | ushort = 1; /* biPlanes: must be 1 */ | 221 | uint16 = 1; /* biPlanes: must be 1 */ |
221 | dwrite(&ushort, sizeof(ushort), bmpP); | 222 | dwrite(&uint16, sizeof(uint16), bmpP); |
222 | ushort = 8; /* biBitCount: 8bitColor */ | 223 | uint16 = 8; /* biBitCount: 8bitColor */ |
223 | dwrite(&ushort, sizeof(ushort), bmpP); | 224 | dwrite(&uint16, sizeof(uint16), bmpP); |
224 | ulong = 0; /* biCompression: noCompression(BI_RGB) */ | 225 | uint32 = 0; /* biCompression: noCompression(BI_RGB) */ |
225 | dwrite(&ulong, sizeof(ulong), bmpP); | 226 | dwrite(&uint32, sizeof(uint32), bmpP); |
226 | ulong = 0; /* biSizeImage: when noComprsn, 0 is ok */ | 227 | uint32 = 0; /* biSizeImage: when noComprsn, 0 is ok */ |
227 | dwrite(&ulong, sizeof(ulong), bmpP); | 228 | dwrite(&uint32, sizeof(uint32), bmpP); |
228 | slong = 0; /* biXPelsPerMeter: resolution x; 0 ok */ | 229 | sint32 = 0; /* biXPelsPerMeter: resolution x; 0 ok */ |
229 | dwrite(&slong, sizeof(slong), bmpP); | 230 | dwrite(&sint32, sizeof(sint32), bmpP); |
230 | slong = 0; /* biYPelsPerMeter: res y; 0 is ok */ | 231 | sint32 = 0; /* biYPelsPerMeter: res y; 0 is ok */ |
231 | dwrite(&slong, sizeof(slong), bmpP); | 232 | dwrite(&sint32, sizeof(sint32), bmpP); |
232 | ulong = 0; /* biClrUsed: optimized color palette; not used */ | 233 | uint32 = 0; /* biClrUsed: optimized color palette; not used */ |
233 | dwrite(&ulong, sizeof(ulong), bmpP); | 234 | dwrite(&uint32, sizeof(uint32), bmpP); |
234 | ulong = 0; /* biClrImportant: 0 is ok */ | 235 | uint32 = 0; /* biClrImportant: 0 is ok */ |
235 | dwrite(&ulong, sizeof(ulong), bmpP); | 236 | dwrite(&uint32, sizeof(uint32), bmpP); |
236 | 237 | ||
237 | /* | 238 | /* |
238 | * RGBQUAD[256]: color palette | 239 | * RGBQUAD[256]: color palette |