Class used to interface with the Nokia N5110 LCD.
Fork of N5110 by
Diff: Bitmap.cpp
- Revision:
- 38:92fad278c2c3
- Child:
- 40:c9262294f2e1
diff -r 2d5931a66fba -r 92fad278c2c3 Bitmap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bitmap.cpp Wed Mar 08 14:12:42 2017 +0000 @@ -0,0 +1,34 @@ +#include "Bitmap.h" + +#include <iostream> + +Bitmap::Bitmap(std::vector<int> const &contents, + unsigned int const height, + unsigned int const width) + : + _contents(contents), + _height(height), + _width(width) +{ + // Perform a quick sanity check of the dimensions + if (contents.size() != height * height) { + std::cerr << "Contents of bitmap has size " << contents.size() + << " pixels, but its dimensions were specified as " + << width << " * " << height << " = " << width * height; + } +} + +int Bitmap::get_pixel(unsigned int const row, + unsigned int const column) const +{ + // First check that row and column indices are within bounds + if(column >= _width || row >= _height) + { + std::cerr << "The requested pixel with index " << row << "," << column + << "is outside the bitmap dimensions: " << _width << "," + << _height; + } + + // Now return the pixel value, using row-major indexing + return _contents[row * _width + column]; +} \ No newline at end of file