TFTBMP.pde and BMP file format confusion

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sgomes
 
Posts: 7
Joined: Wed Nov 30, 2011 6:11 pm

TFTBMP.pde and BMP file format confusion

Post by sgomes »

Looking at the BMP file format on http://en.wikipedia.org/wiki/BMP_file_format I see that in the 24bpp format Example 1 there are two "padding" bytes between pairs of pixels. I don't see these "padding" bytes taken into consideration in the TFTBMP.pde code.

Can someone help me understand either the error in wikipedia, the error in the code or the (likely) error in my thinking?

Shannon

User avatar
sgomes
 
Posts: 7
Joined: Wed Nov 30, 2011 6:11 pm

Re: TFTBMP.pde and BMP file format confusion

Post by sgomes »

should have said "rows" of pixels instead of "pairs". The example is 2x2 pixels. But the question remains the same.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: TFTBMP.pde and BMP file format confusion

Post by pburgess »

I think you might be on to something. By freak chance I'm waiting here for UPS to deliver one of these displays, so I won't be able to confirm until later. The example images all work out to multiples of 4, so there's no padding required there, but I'll try throwing some funny image sizes at it, see what happens.

User avatar
len17
 
Posts: 394
Joined: Sat Mar 14, 2009 7:20 pm

Re: TFTBMP.pde and BMP file format confusion

Post by len17 »

If you need any help dealing with the BMP file format, let me know. I know more about it than I ever wanted to. :roll:

User avatar
len17
 
Posts: 394
Joined: Sat Mar 14, 2009 7:20 pm

Re: TFTBMP.pde and BMP file format confusion

Post by len17 »

I took a look at the tftbmp.pde example in the TFTLCD library (that's the one we're talking about, right?) and I found a couple of problems:

1. Bitmap row padding (as suggested above): Each row of pixels in the file is padded out to a multiple of 4 bytes. The padding bytes, if any, must be skipped when reading the file. The sketch doesn't do that, which will cause the bitmap to be displayed incorrectly if its width isn't a multiple of 4.

2. Top-down bitmaps: The bitmap height field (BITMAPINFOHEADER.biHeight) may be negative. This indicates that the bitmap rows are stored in top-down order instead of the usual bottom-up. This isn't commonly done, but I have seen it on occasion. tftbmp.pde doesn't handle this case - I think it will just display nothing.

User avatar
sgomes
 
Posts: 7
Joined: Wed Nov 30, 2011 6:11 pm

Re: TFTBMP.pde and BMP file format confusion

Post by sgomes »

It sounds like I wasn't off base. I'm wiring up my display tonight. Probably by tomorrow I can put this all to a test. I sense this forum isn't the right place to bring it to the attention of Adafruit. Is there a place to post bug reports? It sounds like something small but I really hate fighting to bring up a new project only to find out it was a code bug from something that was supposedly working.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: TFTBMP.pde and BMP file format confusion

Post by adafruit »

all issues should be posted to the github repository

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”