This class represents bitmap/image/texture in system memory where each point/pixel is represented as 1-component value(transparency or mask).
You can find more information in comments below.
class ImageMask
public:
int const &Width;
int const &Height;
const unsigned char* const &Data;
ImageMask(); // Create empty
ImageMask(const int w, const int h); // Create with specified size
ImageMask(const int w, const int h, const unsigned char *data); // Create with specified size and data.
ImageMask(const ImageMask &other); // Copy
ImageMask(ImageMask &&other); // Move
~ImageMask(); // Destructor
const COLUMN &operator[](const int x) const; // Return bitmap column. You can access pixel as bmp[x][y]. This is the fastest access pixel method but it is unsafe, so be sure you are not accessing pixel outside of bitmap
COLUMN &operator[](const int x); // Return bitmap column. You can access pixel as bmp[x][y]. This is the fastest access pixel method but it is unsafe, so be sure you are not accessing pixel outside of bitmap
ImageMask &operator=(const ImageMask &other); // Copy
ImageMask &operator=(ImageMask &&other); // Move
bool operator==(const ImageMask &other) const; // Check if bitmaps are equal
bool operator!=(const ImageMask &other) const; // Check if bitmaps are not equal
unsigned char getPixel(const int x, const int y) const; // Return pixel from specified position. It is safe method of accessing pixel as it checks whether specified coordinates are inside the bitmap. If bitmap is empty, zero pixel will be returned. If coordinates are outside the bitmap, nearest border pixel will be returned. This method is slower than corresponding operators because it check coordinates first
unsigned char getPixel(const int x, const int y, const unsigned char def) const; // Return pixel from specified position or def one if position is outside the bitmap
const bool isEmpty() const; // Check whether it is empty
bool setWidth(const int value); // Set width
bool setHeight(const int value); // Set height
bool setSize(const int w, const int h); // Set size
bool setPixel(const int x, const int y, const unsigned char value); // Set pixel at specified position. It is safe method for setting pixel as it checks whether specified coordinates are inside the bitmap. If coordinates are invalid, no changes will be made. This method is slower than corresponding operators because it check coordinates first
bool setData(const int w, const int h, const unsigned char *data); // Set size and data
};
Following operator is also available.
std::wostream &operator<<(std::wostream &stream, const ImageMask &a); // Output as source code
Namespace: | nitisa |
Include: | Nitisa/Image/ImageMask.h |