67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
#ifndef GAME_BITMAP_H
|
|
#define GAME_BITMAP_H
|
|
|
|
#include <cstdint>
|
|
|
|
#include "../system/Video.h"
|
|
|
|
class Bitmap {
|
|
public:
|
|
Bitmap() = default;
|
|
|
|
~Bitmap();
|
|
|
|
Bitmap(const Bitmap& other);
|
|
Bitmap& operator=(const Bitmap& other);
|
|
|
|
Bitmap(Bitmap &&other) noexcept ;
|
|
Bitmap& operator=(Bitmap &&other) noexcept;
|
|
|
|
Bitmap(uint16_t width, uint16_t height);
|
|
|
|
Bitmap(uint16_t width, uint16_t height, uint8_t* data);
|
|
|
|
[[nodiscard]] uint8_t GetPixel(uint16_t x, uint16_t y) const {
|
|
return _data[y * _width + x];
|
|
}
|
|
|
|
void SetPixel(uint16_t x, uint16_t y, uint8_t value) {
|
|
_data[y * _width + x] = value;
|
|
}
|
|
|
|
uint8_t &operator[](uint32_t offset) {
|
|
return _data[offset];
|
|
}
|
|
|
|
const uint8_t &operator[](uint32_t offset) const {
|
|
return _data[offset];
|
|
}
|
|
|
|
void SetPaletteEntry(uint8_t index, Video::PaletteEntry entry);
|
|
|
|
[[nodiscard]] Video::PaletteEntry GetPaletteEntry(uint8_t index) const;
|
|
|
|
[[nodiscard]] uint16_t GetWidth() const {
|
|
return _width;
|
|
}
|
|
|
|
[[nodiscard]] uint16_t GetHeight() const {
|
|
return _height;
|
|
}
|
|
|
|
void clear();
|
|
|
|
private:
|
|
uint16_t _width{0};
|
|
uint16_t _height{0};
|
|
uint8_t *_data{nullptr};
|
|
|
|
Video::PaletteEntry _pal[256]{};
|
|
|
|
void copyFrom(const Bitmap& other);
|
|
void moveFrom(Bitmap&& other) noexcept;
|
|
};
|
|
|
|
|
|
#endif //GAME_BITMAP_H
|