Bitmap.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. explicit operator T *();
  28. explicit operator const T *() const;
  29. operator BitmapRef<T, N>();
  30. operator BitmapConstRef<T, N>() const;
  31. private:
  32. T *pixels;
  33. int w, h;
  34. };
  35. }
  36. #include "Bitmap.hpp"