Small bitmap-library to use with monocrome displays.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TinyBitmap.h Source File

TinyBitmap.h

00001 // ------------- MIT-LICENCE -------------
00002 //
00003 //Copyright 2017 Theo Bestenlehner
00004 //
00005 //Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the 
00006 //Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
00007 //and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
00008 //
00009 //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00010 //
00011 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
00012 //PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
00013 //OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00014 
00015 
00016 #ifndef TINYBITMAP_H_
00017 #define TINYBITMAP_H_
00018 
00019 class TinyBitmap
00020 {
00021 private:
00022     int _IMAGEWIDTH;
00023     int _IMAGEHEIGHT;
00024     int _COMMANDBYTES;
00025     int _BITMAPLAYOUT;
00026     char *_FRAMEBUFFER;
00027 
00028     char Bit0;
00029     char Bit1;
00030     char Bit2;
00031     char Bit3;
00032     char Bit4;
00033     char Bit5;
00034     char Bit6;
00035     char Bit7;
00036     
00037 public:
00038     TinyBitmap(int width, int height, char *framebuffer, int commandbytes = 0, int bitmaplayout = 0x00);//Constructor; creates a bitmap-handler with the given size and layout, can also leave some space for command-bytes to control a display. The bitmap (char[]) itself has to be created seperately.
00039 
00040     void DrawPixel(int x, int y); //Draws a single pixel
00041     void DrawLine(int x1, int y1, int x2, int y2);//Draws a line between two points
00042     void DrawCircle(int x, int y, int radius);//Draws a circle
00043     void DrawRectangle(int x1, int y1, int x2, int y2); //Draws a rectangle. The coordinates are the opposite corners
00044     void DrawLineDirection(int x, int y, int degree, int lenght); //Draws a line from a point into a direction with a given length. 0° is from the starting point to the right.
00045     void DrawText(int x, int y, char *CharArray, bool UseLargeFont = false); //Draws basic text in two different sizes on the given location.
00046     void ClearScreen(); //Clears the content of the bitmap to zeros
00047 };
00048 #endif