Mateo Gomez-Randulfe / Mbed 2 deprecated The_Children_of_Cronos

Dependencies:   mbed

Fork of The_Children_of_Cronos_el15mggr by ELEC2645 (2016/17)

Committer:
matirc
Date:
Tue Jul 18 09:55:49 2017 +0000
Revision:
5:4111d3255f24
Parent:
4:466cda7cae42
Final version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
matirc 4:466cda7cae42 1 #ifndef BITMAP_H
matirc 4:466cda7cae42 2 #define BITMAP_H
matirc 4:466cda7cae42 3
matirc 4:466cda7cae42 4 #include <vector>
matirc 4:466cda7cae42 5
matirc 4:466cda7cae42 6 // Forward declarations
matirc 4:466cda7cae42 7 class N5110;
matirc 4:466cda7cae42 8
matirc 4:466cda7cae42 9 /**
matirc 4:466cda7cae42 10 * @brief A black & white bitmap that can be rendered on an N5110 screen
matirc 4:466cda7cae42 11 * @author Alex Valavanis <a.valavanis@leeds.ac.uk>
matirc 4:466cda7cae42 12 *
matirc 4:466cda7cae42 13 * @code
matirc 4:466cda7cae42 14 // First declare the pixel map data using '1' for black,
matirc 4:466cda7cae42 15 // or '0' for white pixels
matirc 4:466cda7cae42 16 static int sprite_data[] = {
matirc 4:466cda7cae42 17 0,0,1,0,0,
matirc 4:466cda7cae42 18 0,1,1,1,0,
matirc 4:466cda7cae42 19 0,0,1,0,0,
matirc 4:466cda7cae42 20 0,1,1,1,0,
matirc 4:466cda7cae42 21 1,1,1,1,1,
matirc 4:466cda7cae42 22 1,1,1,1,1,
matirc 4:466cda7cae42 23 1,1,0,1,1,
matirc 4:466cda7cae42 24 1,1,0,1,1
matirc 4:466cda7cae42 25 };
matirc 4:466cda7cae42 26
matirc 4:466cda7cae42 27 // Instantiate the Bitmap object using the data above
matirc 4:466cda7cae42 28 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite
matirc 4:466cda7cae42 29
matirc 4:466cda7cae42 30 // We can render the bitmap wherever we want on the screen
matirc 4:466cda7cae42 31 sprite.render(lcd, 20, 6); // x and y locations for rendering
matirc 4:466cda7cae42 32 sprite.render(lcd, 30, 10);
matirc 4:466cda7cae42 33
matirc 4:466cda7cae42 34 // We can also print its values to the terminal
matirc 4:466cda7cae42 35 sprite.print();
matirc 4:466cda7cae42 36 * @endcode
matirc 4:466cda7cae42 37 */
matirc 4:466cda7cae42 38 class Bitmap
matirc 4:466cda7cae42 39 {
matirc 4:466cda7cae42 40 private:
matirc 4:466cda7cae42 41 /**
matirc 4:466cda7cae42 42 * @brief The contents of the drawing, with pixels stored in row-major order
matirc 4:466cda7cae42 43 * @details '1' represents a black pixel; '0' represents white
matirc 4:466cda7cae42 44 */
matirc 4:466cda7cae42 45 std::vector<int> _contents;
matirc 4:466cda7cae42 46
matirc 4:466cda7cae42 47 unsigned int _height; ///< The height of the drawing in pixels
matirc 4:466cda7cae42 48 unsigned int _width; ///< The width of the drawing in pixels
matirc 4:466cda7cae42 49
matirc 4:466cda7cae42 50 public:
matirc 4:466cda7cae42 51 Bitmap(int const *contents,
matirc 4:466cda7cae42 52 unsigned int const height,
matirc 4:466cda7cae42 53 unsigned int const width);
matirc 4:466cda7cae42 54
matirc 4:466cda7cae42 55 int get_pixel(unsigned int const row,
matirc 4:466cda7cae42 56 unsigned int const column) const;
matirc 4:466cda7cae42 57
matirc 4:466cda7cae42 58 void print() const;
matirc 4:466cda7cae42 59
matirc 4:466cda7cae42 60 void render(N5110 &lcd,
matirc 4:466cda7cae42 61 unsigned int const x0,
matirc 4:466cda7cae42 62 unsigned int const y0) const;
matirc 4:466cda7cae42 63 };
matirc 4:466cda7cae42 64
matirc 4:466cda7cae42 65 #endif // BITMAP_H