Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Bitmap.h
00001 /** Bitmap Class 00002 * @brief Does nothing useful 00003 * @author Du Xianjie 00004 * @date May, 2019 00005 */ 00006 #ifndef BITMAP_H 00007 #define BITMAP_H 00008 00009 #include <vector> 00010 00011 // Forward declarations 00012 class N5110; 00013 00014 /** 00015 * @brief A black & white bitmap that can be rendered on an N5110 screen 00016 * @author Alex Valavanis <a.valavanis@leeds.ac.uk> 00017 * 00018 * @code 00019 // First declare the pixel map data using '1' for black, 00020 // or '0' for white pixels 00021 static int sprite_data[] = { 00022 0,0,1,0,0, 00023 0,1,1,1,0, 00024 0,0,1,0,0, 00025 0,1,1,1,0, 00026 1,1,1,1,1, 00027 1,1,1,1,1, 00028 1,1,0,1,1, 00029 1,1,0,1,1 00030 }; 00031 00032 // Instantiate the Bitmap object using the data above 00033 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite 00034 00035 // We can render the bitmap wherever we want on the screen 00036 sprite.render(lcd, 20, 6); // x and y locations for rendering 00037 sprite.render(lcd, 30, 10); 00038 00039 // We can also print its values to the terminal 00040 sprite.print(); 00041 * @endcode 00042 */ 00043 class Bitmap 00044 { 00045 private: 00046 /** 00047 * @brief The contents of the drawing, with pixels stored in row-major order 00048 * @details '1' represents a black pixel; '0' represents white 00049 */ 00050 std::vector<int> _contents; 00051 00052 unsigned int _height; ///< The height of the drawing in pixels 00053 unsigned int _width; ///< The width of the drawing in pixels 00054 00055 public: 00056 Bitmap(int const *contents, 00057 unsigned int const height, 00058 unsigned int const width); 00059 00060 int get_pixel (unsigned int const row, 00061 unsigned int const column) const; 00062 00063 void print() const; 00064 00065 void render(N5110 &lcd, 00066 unsigned int const x0, 00067 unsigned int const y0) const; 00068 }; 00069 00070 #endif // BITMAP_H
Generated on Mon Jul 18 2022 14:19:10 by
