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/stat.h> /* stat() */
|
||||||
#include <sys/types.h> /* stat ? */
|
#include <sys/types.h> /* stat ? */
|
||||||
#include <ctype.h> /* isdigit() */
|
#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 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 */
|
#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
|
* LSB .. Least Significant Byte first (LittleEndian) e.g. Intel Pentium
|
||||||
*/
|
*/
|
||||||
void checkEndian(void){
|
void checkEndian(void){
|
||||||
unsigned long ulong = 0x12345678;
|
uint32_t uint32 = 0x12345678;
|
||||||
unsigned char *ucharP;
|
unsigned char *ucharP;
|
||||||
|
|
||||||
ucharP = (unsigned char *)(&ulong);
|
ucharP = (unsigned char *)(&uint32);
|
||||||
if(*ucharP == 0x78){
|
if(*ucharP == 0x78){
|
||||||
d_printf("LSB 0x%x\n", *ucharP);
|
d_printf("LSB 0x%x\n", *ucharP);
|
||||||
endian = 1;
|
endian = 1;
|
||||||
|
@ -166,9 +167,9 @@ void writeBmpFile(unsigned char *bitmapP, int spacing, int colchar, FILE *bmpP){
|
||||||
int bmppad; /* number of padding pixels */
|
int bmppad; /* number of padding pixels */
|
||||||
unsigned long bmpTotalSize; /* bmp filesize (byte) */
|
unsigned long bmpTotalSize; /* bmp filesize (byte) */
|
||||||
/* bmp-lines needs to be long alined and padded with 0 */
|
/* bmp-lines needs to be long alined and padded with 0 */
|
||||||
unsigned long ulong;
|
uint32_t uint32;
|
||||||
unsigned short ushort;
|
uint16_t uint16;
|
||||||
signed long slong;
|
int32_t sint32;
|
||||||
unsigned char uchar;
|
unsigned char uchar;
|
||||||
int i,x,y,g,tmp;
|
int i,x,y,g,tmp;
|
||||||
int rowchar; /* number of row glyphs */
|
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;
|
bmppad = ((bmpw + 3) / 4 * 4) - bmpw;
|
||||||
bmpTotalSize = (bmpw + bmppad) * bmph
|
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);
|
v_printf(" BMP filesize = %d bytes\n", (int)bmpTotalSize);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BITMAPFILEHEADER struct
|
* BITMAPFILEHEADER struct
|
||||||
*/
|
*/
|
||||||
ushort = 0x4d42; /* 4d = 'M', 42 = 'B' */
|
uint16 = 0x4d42; /* 4d = 'M', 42 = 'B' */
|
||||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||||
ulong = bmpTotalSize;
|
uint32 = bmpTotalSize;
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
ushort = 0x00;
|
uint16 = 0x00;
|
||||||
dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */
|
dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */
|
||||||
dwrite(&ushort, sizeof(ushort), bmpP); /* reserved as 0 */
|
dwrite(&uint16, sizeof(uint16), bmpP); /* reserved as 0 */
|
||||||
|
|
||||||
/* bfOffBits: offset to image-data array */
|
/* bfOffBits: offset to image-data array */
|
||||||
ulong = sizeof(long)*11 + sizeof(short)*5 + sizeof(char)*4*256;
|
uint32 = sizeof(int32_t)*11 + sizeof(int16_t)*5 + sizeof(char)*4*256;
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BITMAPINFOHEADER struct
|
* BITMAPINFOHEADER struct
|
||||||
*/
|
*/
|
||||||
ulong = 40; /* when Windows-BMP, this is 40 */
|
uint32 = 40; /* when Windows-BMP, this is 40 */
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
slong = bmpw; /* biWidth */
|
sint32 = bmpw; /* biWidth */
|
||||||
dwrite(&slong, sizeof(slong), bmpP);
|
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||||
slong = bmph; /* biHeight: down-top */
|
sint32 = bmph; /* biHeight: down-top */
|
||||||
dwrite(&slong, sizeof(slong), bmpP);
|
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||||
ushort = 1; /* biPlanes: must be 1 */
|
uint16 = 1; /* biPlanes: must be 1 */
|
||||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||||
ushort = 8; /* biBitCount: 8bitColor */
|
uint16 = 8; /* biBitCount: 8bitColor */
|
||||||
dwrite(&ushort, sizeof(ushort), bmpP);
|
dwrite(&uint16, sizeof(uint16), bmpP);
|
||||||
ulong = 0; /* biCompression: noCompression(BI_RGB) */
|
uint32 = 0; /* biCompression: noCompression(BI_RGB) */
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
ulong = 0; /* biSizeImage: when noComprsn, 0 is ok */
|
uint32 = 0; /* biSizeImage: when noComprsn, 0 is ok */
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
slong = 0; /* biXPelsPerMeter: resolution x; 0 ok */
|
sint32 = 0; /* biXPelsPerMeter: resolution x; 0 ok */
|
||||||
dwrite(&slong, sizeof(slong), bmpP);
|
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||||
slong = 0; /* biYPelsPerMeter: res y; 0 is ok */
|
sint32 = 0; /* biYPelsPerMeter: res y; 0 is ok */
|
||||||
dwrite(&slong, sizeof(slong), bmpP);
|
dwrite(&sint32, sizeof(sint32), bmpP);
|
||||||
ulong = 0; /* biClrUsed: optimized color palette; not used */
|
uint32 = 0; /* biClrUsed: optimized color palette; not used */
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
ulong = 0; /* biClrImportant: 0 is ok */
|
uint32 = 0; /* biClrImportant: 0 is ok */
|
||||||
dwrite(&ulong, sizeof(ulong), bmpP);
|
dwrite(&uint32, sizeof(uint32), bmpP);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RGBQUAD[256]: color palette
|
* RGBQUAD[256]: color palette
|
||||||
|
|
Loading…
Reference in a new issue