summaryrefslogtreecommitdiff
path: root/tools/easylogo
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-12-18 04:29:55 -0500
committerWolfgang Denk <wd@denx.de>2008-01-09 15:10:08 +0100
commitfc6414eca55f1fc108fb12fc8cdc43bd8b4463f9 (patch)
tree7008b67093b4b31df2a70e6135507f849a5ba2d9 /tools/easylogo
parent38d299c2db81bd889c601b5dfc12c4e83ef83333 (diff)
downloadu-boot-imx-fc6414eca55f1fc108fb12fc8cdc43bd8b4463f9.zip
u-boot-imx-fc6414eca55f1fc108fb12fc8cdc43bd8b4463f9.tar.gz
u-boot-imx-fc6414eca55f1fc108fb12fc8cdc43bd8b4463f9.tar.bz2
fix easylogo on big endian dev systems
didnt realize how out of shape easylogo actually was until i tried using it. this patch does byte swapping as need be on the input tga header since the tga is in little endian but the host could just as well be big endian. i didnt bother using bswap macros or such stuff from system headers as nothing in POSIX dictates byte swapping functionality. Signed-Off-By: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'tools/easylogo')
-rw-r--r--tools/easylogo/easylogo.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/easylogo/easylogo.c b/tools/easylogo/easylogo.c
index 59f9ae7..6f2aaa6 100644
--- a/tools/easylogo/easylogo.c
+++ b/tools/easylogo/easylogo.c
@@ -127,6 +127,16 @@ void printlogo_yuyv (unsigned short *data, int w, int h)
}
}
+static inline unsigned short le16_to_cpu (unsigned short val)
+{
+ union {
+ unsigned char pval[2];
+ unsigned short val;
+ } swapped;
+ swapped.val = val;
+ return (swapped.pval[1] << 8) + swapped.pval[0];
+}
+
int image_load_tga (image_t *image, char *filename)
{
FILE *file ;
@@ -140,6 +150,14 @@ int image_load_tga (image_t *image, char *filename)
fread(&header, sizeof(header), 1, file);
+ /* byte swap: tga is little endian, host is ??? */
+ header.ColorMapOrigin = le16_to_cpu (header.ColorMapOrigin);
+ header.ColorMapLenght = le16_to_cpu (header.ColorMapLenght);
+ header.ImageXOrigin = le16_to_cpu (header.ImageXOrigin);
+ header.ImageYOrigin = le16_to_cpu (header.ImageYOrigin);
+ header.ImageWidth = le16_to_cpu (header.ImageWidth);
+ header.ImageHeight = le16_to_cpu (header.ImageHeight);
+
image->width = header.ImageWidth ;
image->height = header.ImageHeight ;