Small bitmap-library to use with monocrome displays.

Committer:
glx
Date:
Fri Aug 31 16:10:15 2018 +0000
Revision:
6:c558f38d07ca
Parent:
4:5d6f6e0191b8
Bugfix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
glx 3:457eaa2c6ed5 1 // ------------- MIT-LICENCE -------------
glx 3:457eaa2c6ed5 2 //
glx 3:457eaa2c6ed5 3 //Copyright 2017 Theo Bestenlehner
glx 3:457eaa2c6ed5 4 //
glx 3:457eaa2c6ed5 5 //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
glx 3:457eaa2c6ed5 6 //Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
glx 3:457eaa2c6ed5 7 //and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
glx 3:457eaa2c6ed5 8 //
glx 3:457eaa2c6ed5 9 //The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
glx 3:457eaa2c6ed5 10 //
glx 3:457eaa2c6ed5 11 //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
glx 3:457eaa2c6ed5 12 //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
glx 3:457eaa2c6ed5 13 //OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
glx 3:457eaa2c6ed5 14
glx 3:457eaa2c6ed5 15
glx 0:f068fae80257 16 #ifndef TINYBITMAP_H_
glx 0:f068fae80257 17 #define TINYBITMAP_H_
glx 0:f068fae80257 18
glx 0:f068fae80257 19 class TinyBitmap
glx 0:f068fae80257 20 {
glx 0:f068fae80257 21 private:
glx 0:f068fae80257 22 int _IMAGEWIDTH;
glx 0:f068fae80257 23 int _IMAGEHEIGHT;
glx 0:f068fae80257 24 int _COMMANDBYTES;
glx 0:f068fae80257 25 int _BITMAPLAYOUT;
glx 4:5d6f6e0191b8 26 char *_FRAMEBUFFER;
glx 0:f068fae80257 27
glx 0:f068fae80257 28 char Bit0;
glx 0:f068fae80257 29 char Bit1;
glx 0:f068fae80257 30 char Bit2;
glx 0:f068fae80257 31 char Bit3;
glx 0:f068fae80257 32 char Bit4;
glx 0:f068fae80257 33 char Bit5;
glx 0:f068fae80257 34 char Bit6;
glx 0:f068fae80257 35 char Bit7;
glx 0:f068fae80257 36
glx 0:f068fae80257 37 public:
glx 4:5d6f6e0191b8 38 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.
glx 0:f068fae80257 39
glx 4:5d6f6e0191b8 40 void DrawPixel(int x, int y); //Draws a single pixel
glx 4:5d6f6e0191b8 41 void DrawLine(int x1, int y1, int x2, int y2);//Draws a line between two points
glx 4:5d6f6e0191b8 42 void DrawCircle(int x, int y, int radius);//Draws a circle
glx 4:5d6f6e0191b8 43 void DrawRectangle(int x1, int y1, int x2, int y2); //Draws a rectangle. The coordinates are the opposite corners
glx 4:5d6f6e0191b8 44 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.
glx 4:5d6f6e0191b8 45 void DrawText(int x, int y, char *CharArray, bool UseLargeFont = false); //Draws basic text in two different sizes on the given location.
glx 4:5d6f6e0191b8 46 void ClearScreen(); //Clears the content of the bitmap to zeros
glx 0:f068fae80257 47 };
glx 0:f068fae80257 48 #endif