graphlcd-base/glcdgraphics/bitmap.h
changeset 4 df6a40031aa5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/graphlcd-base/glcdgraphics/bitmap.h	Wed Feb 06 17:32:55 2008 +0000
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 + * GraphLCD graphics library
     1.6 + *
     1.7 + * bitmap.h  -  cBitmap class
     1.8 + *
     1.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
    1.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
    1.11 + *
    1.12 + * This file is released under the GNU General Public License. Refer
    1.13 + * to the COPYING file distributed with this package.
    1.14 + *
    1.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
    1.16 + */
    1.17 +
    1.18 +#ifndef _GLCDGRAPHICS_BITMAP_H_
    1.19 +#define _GLCDGRAPHICS_BITMAP_H_
    1.20 +
    1.21 +#include <string>
    1.22 +
    1.23 +namespace GLCD
    1.24 +{
    1.25 +
    1.26 +enum eColor
    1.27 +{
    1.28 +    clrBlack,
    1.29 +    clrWhite
    1.30 +};
    1.31 +
    1.32 +class cFont;
    1.33 +
    1.34 +class cBitmap
    1.35 +{
    1.36 +protected:
    1.37 +    int width;
    1.38 +    int height;
    1.39 +    int lineSize;
    1.40 +    unsigned char * bitmap;
    1.41 +
    1.42 +public:
    1.43 +    cBitmap(int width, int height, unsigned char * data = NULL);
    1.44 +    cBitmap(const cBitmap & b);
    1.45 +    ~cBitmap();
    1.46 +
    1.47 +    int Width() const { return width; }
    1.48 +    int Height() const { return height; }
    1.49 +    int LineSize() const { return lineSize; }
    1.50 +    const unsigned char * Data() const { return bitmap; }
    1.51 +
    1.52 +    void Clear();
    1.53 +    void Invert();
    1.54 +    void DrawPixel(int x, int y, eColor color);
    1.55 +    void Draw8Pixels(int x, int y, unsigned char pixels, eColor color);
    1.56 +    void DrawLine(int x1, int y1, int x2, int y2, eColor color);
    1.57 +    void DrawHLine(int x1, int y, int x2, eColor color);
    1.58 +    void DrawVLine(int x, int y1, int y2, eColor color);
    1.59 +    void DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled);
    1.60 +    void DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int size);
    1.61 +    void DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants);
    1.62 +    void DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type);
    1.63 +    void DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color);
    1.64 +    int DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
    1.65 +                 eColor color = clrBlack, bool proportional = true, int skipPixels = 0);
    1.66 +    int DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
    1.67 +                      eColor color = clrBlack, int skipPixels = 0);
    1.68 +
    1.69 +    cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const;
    1.70 +    unsigned char GetPixel(int x, int y) const;
    1.71 +
    1.72 +    bool LoadPBM(const std::string & fileName);
    1.73 +    void SavePBM(const std::string & fileName);
    1.74 +};
    1.75 +
    1.76 +} // end of namespace
    1.77 +
    1.78 +#endif