From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [patch] fix easylogo on big endian dev systems
Date: Tue, 18 Dec 2007 04:29:55 -0500 [thread overview]
Message-ID: <200712180429.55400.vapier@gentoo.org> (raw)
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>
---
--- a/tools/easylogo/easylogo.c
+++ b/tools/easylogo/easylogo.c
@@ -125,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 ;
@@ -138,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 ;
next reply other threads:[~2007-12-18 9:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-18 9:29 Mike Frysinger [this message]
2008-01-09 14:15 ` [U-Boot-Users] [patch] fix easylogo on big endian dev systems Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200712180429.55400.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox