Make bdf2bmp work on 64 bit hosts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18416 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5420c3f672
commit
7a22ba36cb
1 changed files with 38 additions and 37 deletions
|
@ -53,6 +53,7 @@
|
|||
#include <sys/stat.h> /* stat() */
|
||||
#include <sys/types.h> /* stat ? */
|
||||
#include <ctype.h> /* isdigit() */
|
||||
#include <stdint.h> /* int types */
|
||||
|
||||
#define LINE_CHARMAX 1000 /* number of max characters in bdf-font-file; number is without reason */
|
||||
#define FILENAME_CHARMAX 256 /* number of max characters in filenames; number is without reason */
|
||||
|
@ -109,10 +110,10 @@ int main(int argc, char *argv[]);
|
|||
* LSB .. Least Significant Byte first (LittleEndian) e.g. Intel Pentium
|
||||
*/
|
||||
void checkEndian(void){
|
||||
unsigned long ulong = 0x12345678;
|
||||
uint32_t uint32 = 0x12345678;
|
||||
unsigned char *ucharP;
|
||||
|
||||
ucharP = (unsigned char *)(&ulong);
|
||||
ucharP = (unsigned char *)(&uint32);
|
||||
if(*ucharP == 0x78){
|
||||
d_printf("LSB 0x%x\n", *ucharP);
|
||||
endian = 1;
|
||||
|
@ -166,9 +167,9 @@ void writeBmpFile(unsigned char *bitmapP, int spacing, int colchar, FILE *bmpP){
|
|||
int bmppad; /* number of padding pixels */
|
||||
unsigned long bmpTotalSize; /* bmp filesize (byte) */
|
||||
/* bmp-lines needs to be long alined and padded with 0 */
|
||||
unsigned long ulong;
|
||||
unsigned short ushort;
|
||||
signed long slong;
|
||||
uint32_t uint32;
|
||||
uint16_t uint16;
|
||||
int32_t sint32;
|
||||
unsigned char uchar;
|
||||
int i,x,y,g,tmp;
|
||||
int rowchar; /* number of row glyphs */
|
||||
|
@ -188,51 +189,51 @@ void writeBmpFile(unsigned char *bitmapP, int spacing, int colchar, FILE *bmpP){
|
|||
|
||||
bmppad = ((bmpw + 3) / 4 * 4) - bmpw;
|
||||
bmpTotalSize = (bmpw + bmppad) * bmph
|
||||
+ sizeof(long)*11 + sizeof(short)*5 + sizeof(char)*4*256;
|
||||
+ sizeof(int32_t)*11 + sizeof(int16_t)*5 + sizeof(char)*4*256;
|
||||
v_printf(" BMP filesize = %d bytes\n", (int)bmpTotalSize);
|
||||
|
||||
|
||||
/*
|
||||
* BITMAPFILEHEADER struct
|
||||
*/
|
||||
ushort = 0x4d42; /* 4d = 'M', 42 = 'B' */
|
||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
||||
ulong = bmpTotalSize;
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
ushort = 0x00;
|
||||
dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */
|
||||
dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */
|
||||
uint16 = 0x4d42; /* 4d = 'M', 42 = 'B' */
|
||||
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||
uint32 = bmpTotalSize;
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
uint16 = 0x00;
|
||||
dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */
|
||||
dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */
|
||||
|
||||
/* bfOffBits: offset to image-data array */
|
||||
ulong = sizeof(long)*11 + sizeof(short)*5 + sizeof(char)*4*256;
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
uint32 = sizeof(int32_t)*11 + sizeof(int16_t)*5 + sizeof(char)*4*256;
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
|
||||
|
||||
/*
|
||||
* BITMAPINFOHEADER struct
|
||||
*/
|
||||
ulong = 40; /* when Windows-BMP, this is 40 */
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
slong = bmpw; /* biWidth */
|
||||
dwrite(&slong, sizeof(slong), bmpP);
|
||||
slong = bmph; /* biHeight: down-top */
|
||||
dwrite(&slong, sizeof(slong), bmpP);
|
||||
ushort = 1; /* biPlanes: must be 1 */
|
||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
||||
ushort = 8; /* biBitCount: 8bitColor */
|
||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
||||
ulong = 0; /* biCompression: noCompression(BI_RGB) */
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
ulong = 0; /* biSizeImage: when noComprsn, 0 is ok */
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
slong = 0; /* biXPelsPerMeter: resolution x; 0 ok */
|
||||
dwrite(&slong, sizeof(slong), bmpP);
|
||||
slong = 0; /* biYPelsPerMeter: res y; 0 is ok */
|
||||
dwrite(&slong, sizeof(slong), bmpP);
|
||||
ulong = 0; /* biClrUsed: optimized color palette; not used */
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
ulong = 0; /* biClrImportant: 0 is ok */
|
||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
||||
uint32 = 40; /* when Windows-BMP, this is 40 */
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
sint32 = bmpw; /* biWidth */
|
||||
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||
sint32 = bmph; /* biHeight: down-top */
|
||||
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||
uint16 = 1; /* biPlanes: must be 1 */
|
||||
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||
uint16 = 8; /* biBitCount: 8bitColor */
|
||||
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||
uint32 = 0; /* biCompression: noCompression(BI_RGB) */
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
uint32 = 0; /* biSizeImage: when noComprsn, 0 is ok */
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
sint32 = 0; /* biXPelsPerMeter: resolution x; 0 ok */
|
||||
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||
sint32 = 0; /* biYPelsPerMeter: res y; 0 is ok */
|
||||
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||
uint32 = 0; /* biClrUsed: optimized color palette; not used */
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
uint32 = 0; /* biClrImportant: 0 is ok */
|
||||
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||
|
||||
/*
|
||||
* RGBQUAD[256]: color palette
|
||||
|
|
Loading…
Reference in a new issue