Bitmap Parser
A class to read bitmaps from a file and display them on a screen. Bitmaps are loaded through the constructor.
Library availiable at http://mbed.co.uk/projects/cookbook/svn/BitmapFile/trunk
Example code:
#include "mbed.h"
#include "BitmapFile.h"
#include "MobileLCD.h"
LocalFileSystem local("local");
MobileLCD lcd(5, 6, 7, 8, 9);
int main()
{
BitmapFile MyBitmap("/local/test.bmp");
lcd.background(0x8f8f8f);
lcd.cls();
for(int row = 0; row < MyBitmap.getHeight(); row++)
{
int *colors = MyBitmap.getRow(row,false);
lcd.blit(0,MyBitmap.getHeight()-row-1,MyBitmap.getWidth(),1,colors);
delete [] colors;
}
MyBitmap.close();
}
Top Tip!!!
When loading bitmaps from the LocalFileSystem it can take quite a long time because accessing files on the MBED isn't a quick process. What is a lot quicker, is to use an SD Card which you can set to 2GHz spi clock frequency and also, when using the MobileLcd set the spi frequency to 25MHz. Using an SD Card has the added bonus that the MBED does not disconnect from the computer when in use. To use the SD Card "Superquick" system, download these files along with this library and here is an example code, which is virtually the same as the one before, but it is just useful to have it here.
#include "mbed.h"
#include "BitmapFile.h"
#include "MobileLCD.h"
#include "SDFileSystem.h"
SDFileSystem sd(5, 6, 7, 8, "sd");
MobileLCD lcd(11, 12, 13, 16, 15);
int main()
{
BitmapFile MyBitmap("/sd/Bitmap.bmp");
lcd.background(0x8f8f8f);
lcd.cls();
for(int row = 0; row < MyBitmap.getHeight(); row++)
{
int *colors = MyBitmap.getRow(row,false);
lcd.blit(0,MyBitmap.getHeight()-row-1,MyBitmap.getWidth(),1,colors);
delete [] colors;
}
MyBitmap.close();
}