Buffer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/icon.h>
  4. enum PixelColor {
  5. Black, //or
  6. White, //
  7. Flip //not
  8. };
  9. enum DrawMode {
  10. WhiteOnly,
  11. BlackOnly,
  12. WhiteAsBlack,
  13. BlackAsWhite,
  14. WhiteAsInverted,
  15. BlackAsInverted,
  16. };
  17. struct SpriteData;
  18. /**
  19. * @class Buffer
  20. * @brief The Buffer class represents a buffer for storing pixel data.
  21. *
  22. * The Buffer class provides methods for manipulating the pixel data stored in the buffer.
  23. */
  24. class Buffer {
  25. uint8_t _width=0, _height=0;
  26. protected:
  27. bool remove_buffer=true;
  28. public:
  29. uint8_t *data;
  30. Buffer(uint8_t *data, uint8_t w, uint8_t h);
  31. Buffer(uint8_t width, uint8_t height);
  32. virtual ~Buffer();
  33. bool test_pixel(uint8_t x, uint8_t y);
  34. void copy_into(uint8_t *other);
  35. void clear();
  36. bool test_coordinate(int x, int y) const;
  37. void set_pixel(int16_t x, int16_t y, PixelColor draw_mode);
  38. void set_pixel_with_check(int16_t x, int16_t y, PixelColor draw_mode);
  39. void copy_from(uint8_t *other);
  40. uint8_t width() { return _width; }
  41. uint8_t height() { return _height; }
  42. virtual void swap(uint8_t *&buffer);
  43. uint16_t pixel(uint8_t x, uint8_t y);
  44. uint8_t* decode(const Icon *icon);
  45. };