Bitmap.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "BitmapRef.hpp"
  3. namespace msdfgen {
  4. /// A 2D image bitmap with N channels of type T. Pixel memory is managed by the class.
  5. template <typename T, int N = 1>
  6. class Bitmap {
  7. public:
  8. Bitmap();
  9. Bitmap(int width, int height);
  10. Bitmap(const BitmapConstRef<T, N> &orig);
  11. Bitmap(const Bitmap<T, N> &orig);
  12. #ifdef MSDFGEN_USE_CPP11
  13. Bitmap(Bitmap<T, N> &&orig);
  14. #endif
  15. ~Bitmap();
  16. Bitmap<T, N> & operator=(const BitmapConstRef<T, N> &orig);
  17. Bitmap<T, N> & operator=(const Bitmap<T, N> &orig);
  18. #ifdef MSDFGEN_USE_CPP11
  19. Bitmap<T, N> & operator=(Bitmap<T, N> &&orig);
  20. #endif
  21. /// Bitmap width in pixels.
  22. int width() const;
  23. /// Bitmap height in pixels.
  24. int height() const;
  25. T * operator()(int x, int y);
  26. const T * operator()(int x, int y) const;
  27. #ifdef MSDFGEN_USE_CPP11
  28. explicit operator T *();
  29. explicit operator const T *() const;
  30. #else
  31. operator T *();
  32. operator const T *() const;
  33. #endif
  34. operator BitmapRef<T, N>();
  35. operator BitmapConstRef<T, N>() const;
  36. private:
  37. T *pixels;
  38. int w, h;
  39. };
  40. }
  41. #include "Bitmap.hpp"