Olli Vanhoja / gfxLcd

Dependents:   LCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bitmap.h Source File

bitmap.h

Go to the documentation of this file.
00001 /** @file bitmap.h */
00002 #ifndef BITMAP_H_
00003 #define BITMAP_H_
00004 
00005 #include "mbed.h"
00006 #include "lcd.h "
00007 
00008 /** File info structure
00009 */
00010 struct sBitmapInfo {
00011     uint32_t rows;    /**< Number if rows in bitmap. */
00012     uint32_t cols;    /**< Number of colums in bitmap. */
00013     uint32_t offset;
00014     uint16_t bitsPP;
00015 };
00016 
00017 /** bitmapImage class
00018  * 
00019  * This class is used for drawing BMP images.
00020  */
00021 class bitmapImage {
00022 private:
00023     char *filename;
00024     FILE *fp;
00025     unsigned long fileSize;  /**< BMP file size. */
00026     
00027     /** Read integer value from file
00028     *
00029     * @param offset Byte offset.
00030     * @param n Number of bytes.
00031     * @returns Long integer.
00032     */
00033     uint32_t readImageInfo(long offset, int n);
00034 public:
00035     sBitmapInfo fileInfo; /**< File info */
00036 
00037     /** Open BMP bitmap file
00038     *
00039     * @param *inputFilename Path to BMP file.  
00040     */
00041     bitmapImage(char *inputFilename);
00042     
00043     ~bitmapImage();
00044     
00045     /** Draw bitmap to the LCD
00046     *
00047     * \note There is no image buffer in this class instead the image
00048     *       is read from the fs every time it's drawn. This should
00049     *       be still fast enough as mBeds flash is still faster than
00050     *       the LCD.
00051     *
00052     * \warning This class doesn't understand padding so images must be
00053     *          resized to size where paddings isn't needed. Also because
00054     *          of one bit BMP format the iamge width should be divisiable
00055     *          by 8.
00056     *
00057     * @param *glcd Reference to gfxLcd object.
00058     * @param xOffset Start drawing from point x.
00059     * @param yOffset Start drawing from point y.
00060     */
00061     void drawImage(gfxLcd *glcd, int xOffset, int yOffset);
00062 };
00063 #endif
00064