Richard Parker / EALCD

widgets/EAImage.h

Committer:
richardparker
Date:
2010-02-11
Revision:
0:839ecbf5cb2a
Child:
1:f04bcaea1d60

File content as of revision 0:839ecbf5cb2a:

// Copyright 2010 Richard Parker

#ifndef MBED_EAIMAGE_H
#define MBED_EAIMAGE_H

#include "mbed.h"

#include "EAWidget.h"

class EALCD;

/**
 * Class to handle loading and displaying an image.
 * @author Richard Parker
 */
class EAImage: public EAWidget
{
public:
    EAImage();
    ~EAImage();
    
    bool load(const char* path);
    
    inline const char* path() const { return _path; }
    
    inline bool isValid() const { return (_path != NULL); }
    
    virtual void paint(EALCD& lcd);
    virtual void paint(EALCD& lcd, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
    
private:
    struct EABMPHeader {
        unsigned int headerSize;
        unsigned int width;
        unsigned int height;
        unsigned short noColorPlanes;
        unsigned short bitsPerPixel;
        unsigned int compressionType;
        unsigned int bmpSize;
        unsigned int horizontalRes;
        unsigned int verticalRes;
        unsigned int noColors;
        unsigned int noImportantColors;
    };
   
    char* _path;
    unsigned int _dataOffset;
    
    bool _loadHeader(const char* path);
    
};

#endif