TFTBMP.pde and BMP file format confusion

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

TFTBMP.pde and BMP file format confusion

Postby sgomes » Thu Feb 23, 2012 5:39 pm

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
sgomes
 
Posts: 4
Joined: Wed Nov 30, 2011 5:11 pm

Re: TFTBMP.pde and BMP file format confusion

Postby sgomes » Thu Feb 23, 2012 5:43 pm

should have said "rows" of pixels instead of "pairs". The example is 2x2 pixels. But the question remains the same.
sgomes
 
Posts: 4
Joined: Wed Nov 30, 2011 5:11 pm

Re: TFTBMP.pde and BMP file format confusion

Postby pburgess » Thu Feb 23, 2012 6:00 pm

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
pburgess
 
Posts: 1327
Joined: Sun Oct 26, 2008 1:29 am

Re: TFTBMP.pde and BMP file format confusion

Postby Len17 » Thu Feb 23, 2012 7:07 pm

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: 393
Joined: Sat Mar 14, 2009 6:20 pm

Re: TFTBMP.pde and BMP file format confusion

Postby Len17 » Thu Feb 23, 2012 9:50 pm

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
Len17
 
Posts: 393
Joined: Sat Mar 14, 2009 6:20 pm

Re: TFTBMP.pde and BMP file format confusion

Postby sgomes » Thu Feb 23, 2012 11:44 pm

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.
sgomes
 
Posts: 4
Joined: Wed Nov 30, 2011 5:11 pm

Re: TFTBMP.pde and BMP file format confusion

Postby adafruit » Fri Feb 24, 2012 12:13 pm

all issues should be posted to the github repository
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc


Return to General Project help

Who is online

Users browsing this forum: No registered users and 7 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]