graphlcd-base/glcdgraphics/bitmap.h
author root@rika
Wed, 06 Feb 2008 17:32:55 +0000
changeset 4 df6a40031aa5
permissions -rw-r--r--
added graphlcd-base
root@4
     1
/*
root@4
     2
 * GraphLCD graphics library
root@4
     3
 *
root@4
     4
 * bitmap.h  -  cBitmap class
root@4
     5
 *
root@4
     6
 * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
root@4
     7
 *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
root@4
     8
 *
root@4
     9
 * This file is released under the GNU General Public License. Refer
root@4
    10
 * to the COPYING file distributed with this package.
root@4
    11
 *
root@4
    12
 * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
root@4
    13
 */
root@4
    14
root@4
    15
#ifndef _GLCDGRAPHICS_BITMAP_H_
root@4
    16
#define _GLCDGRAPHICS_BITMAP_H_
root@4
    17
root@4
    18
#include <string>
root@4
    19
root@4
    20
namespace GLCD
root@4
    21
{
root@4
    22
root@4
    23
enum eColor
root@4
    24
{
root@4
    25
    clrBlack,
root@4
    26
    clrWhite
root@4
    27
};
root@4
    28
root@4
    29
class cFont;
root@4
    30
root@4
    31
class cBitmap
root@4
    32
{
root@4
    33
protected:
root@4
    34
    int width;
root@4
    35
    int height;
root@4
    36
    int lineSize;
root@4
    37
    unsigned char * bitmap;
root@4
    38
root@4
    39
public:
root@4
    40
    cBitmap(int width, int height, unsigned char * data = NULL);
root@4
    41
    cBitmap(const cBitmap & b);
root@4
    42
    ~cBitmap();
root@4
    43
root@4
    44
    int Width() const { return width; }
root@4
    45
    int Height() const { return height; }
root@4
    46
    int LineSize() const { return lineSize; }
root@4
    47
    const unsigned char * Data() const { return bitmap; }
root@4
    48
root@4
    49
    void Clear();
root@4
    50
    void Invert();
root@4
    51
    void DrawPixel(int x, int y, eColor color);
root@4
    52
    void Draw8Pixels(int x, int y, unsigned char pixels, eColor color);
root@4
    53
    void DrawLine(int x1, int y1, int x2, int y2, eColor color);
root@4
    54
    void DrawHLine(int x1, int y, int x2, eColor color);
root@4
    55
    void DrawVLine(int x, int y1, int y2, eColor color);
root@4
    56
    void DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled);
root@4
    57
    void DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int size);
root@4
    58
    void DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants);
root@4
    59
    void DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type);
root@4
    60
    void DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color);
root@4
    61
    int DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
root@4
    62
                 eColor color = clrBlack, bool proportional = true, int skipPixels = 0);
root@4
    63
    int DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
root@4
    64
                      eColor color = clrBlack, int skipPixels = 0);
root@4
    65
root@4
    66
    cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const;
root@4
    67
    unsigned char GetPixel(int x, int y) const;
root@4
    68
root@4
    69
    bool LoadPBM(const std::string & fileName);
root@4
    70
    void SavePBM(const std::string & fileName);
root@4
    71
};
root@4
    72
root@4
    73
} // end of namespace
root@4
    74
root@4
    75
#endif