1
0
Fork 0
forked from len0rd/rockbox

Patch #5771 by Frederik Vestre: Fix BMP loader to work in 64bit environments (simulator).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11513 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2006-11-11 11:26:42 +00:00
parent 202b7267c2
commit 83e18d982c

View file

@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "inttypes.h"
#include "debug.h"
#include "lcd.h"
#include "file.h"
@ -44,22 +45,22 @@
/* Struct from original code. */
struct Fileheader {
unsigned short Type; /* signature - 'BM' */
unsigned long Size; /* file size in bytes */
unsigned short Reserved1; /* 0 */
unsigned short Reserved2; /* 0 */
unsigned long OffBits; /* offset to bitmap */
unsigned long StructSize; /* size of this struct (40) */
unsigned long Width; /* bmap width in pixels */
unsigned long Height; /* bmap height in pixels */
unsigned short Planes; /* num planes - always 1 */
unsigned short BitCount; /* bits per pixel */
unsigned long Compression; /* compression flag */
unsigned long SizeImage; /* image size in bytes */
long XPelsPerMeter; /* horz resolution */
long YPelsPerMeter; /* vert resolution */
unsigned long ClrUsed; /* 0 -> color table size */
unsigned long ClrImportant; /* important color count */
uint16_t Type; /* signature - 'BM' */
uint32_t Size; /* file size in bytes */
uint16_t Reserved1; /* 0 */
uint16_t Reserved2; /* 0 */
uint32_t OffBits; /* offset to bitmap */
uint32_t StructSize; /* size of this struct (40) */
uint32_t Width; /* bmap width in pixels */
uint32_t Height; /* bmap height in pixels */
uint16_t Planes; /* num planes - always 1 */
uint16_t BitCount; /* bits per pixel */
uint32_t Compression; /* compression flag */
uint32_t SizeImage; /* image size in bytes */
int32_t XPelsPerMeter; /* horz resolution */
int32_t YPelsPerMeter; /* vert resolution */
uint32_t ClrUsed; /* 0 -> color table size */
uint32_t ClrImportant; /* important color count */
} STRUCT_PACKED;
struct rgb_quad { /* Little endian */
@ -70,12 +71,12 @@ struct rgb_quad { /* Little endian */
} STRUCT_PACKED;
/* big endian functions */
static short readshort(short *value) {
static uint16_t readshort(uint16_t *value) {
unsigned char* bytes = (unsigned char*) value;
return bytes[0] | (bytes[1] << 8);
}
static long readlong(long *value) {
static uint32_t readlong(uint32_t *value) {
unsigned char* bytes = (unsigned char*) value;
return (long)bytes[0] | ((long)bytes[1] << 8) |
((long)bytes[2] << 16) | ((long)bytes[3] << 24);