µTasker Forum
September 05, 2010, 06:38:57 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: January 2010: uTasker utFAT version released for M522XX, SAM7X, LM3SXXXX, LPC2XXX and AVR32 - see utFAT board for full details!
Note that Internet Explorer 8 doesn't work with the forum (unless compatibility view is selected); please use Firefox or Chrome (or other well behaved browsers) as alternative!
 
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problem when bad bmp files hang the target  (Read 58 times)
Kevin
Newbie
*
Offline Offline

Posts: 30


View Profile
« on: July 29, 2010, 05:40:28 am »

Mark-

In one of my previous posts I mentioned that my .bmp pictures reduced to fit the tft in photoshop 6.0 had two extra bytes in the length and two extra nulls appended at the end of the file.

When displaying these files utasker would hang.

From what I can tell it looks like fnDisplayBitmap is reading from the file 3 bytes at a time, but at the end there are only two bytes available.  I added the following to fnDisplayBitmap in TFT.c

BMP_Length = (BMP_Length/3) * 3;   //{kevin 1} bmp file must be multiple of color bytes (3 bytes = 24bit)

after BMP_Length is read from the file.  Since it's int math, any file not divisible by 3 is truncated.

This seemed to work fine for me.

-Kevin

Code:
                    BMP_Length = (ptrBMP_info->biSizeImage[3] << 24);    // bit map content length
                    BMP_Length |= (ptrBMP_info->biSizeImage[2] << 16);
                    BMP_Length |= (ptrBMP_info->biSizeImage[1] << 8);
                    BMP_Length |= (ptrBMP_info->biSizeImage[0]);
                    if (BMP_Length == 0) {
                        BMP_Length = (ptrBMP->bmLength[3] << 24);        // if the content length is zero, take it from the header
                        BMP_Length |= (ptrBMP->bmLength[2] << 16);
                        BMP_Length |= (ptrBMP->bmLength[1] << 8);
                        BMP_Length |= (ptrBMP->bmLength[0]);
                        BMP_Length -= ptrBMP->bmOffBits[0];
                    }
BMP_Length = (BMP_Length/3) * 3; //{kevin 1} bmp file must be multiple of color bytes (3 bytes = 24bit)

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Copyright © 2010 utasker.com. Webdesign and Hosting by e-future.ch 2010
Valid XHTML 1.0! Valid CSS!
Page created in 0.06 seconds with 17 queries.