DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ImageBase.hpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DGL_IMAGE_BASE_HPP_INCLUDED
  17. #define DGL_IMAGE_BASE_HPP_INCLUDED
  18. #include "Geometry.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. /**
  22. Base DGL Image class.
  23. This is an Image class that handles raw image data in pixels.
  24. It is an abstract class that provides the common methods to build on top.
  25. Cairo and OpenGL Image classes are based upon this one.
  26. @see Image
  27. */
  28. class ImageBase
  29. {
  30. protected:
  31. /**
  32. Constructor for a null Image.
  33. */
  34. ImageBase();
  35. /**
  36. Constructor using raw image data.
  37. @note @a rawData must remain valid for the lifetime of this Image.
  38. */
  39. ImageBase(const char* const rawData, const uint width, const uint height);
  40. /**
  41. Constructor using raw image data.
  42. @note @a rawData must remain valid for the lifetime of this Image.
  43. */
  44. ImageBase(const char* const rawData, const Size<uint>& size);
  45. /**
  46. Constructor using another image data.
  47. */
  48. ImageBase(const ImageBase& image);
  49. public:
  50. /**
  51. Destructor.
  52. */
  53. virtual ~ImageBase();
  54. /**
  55. Check if this image is valid.
  56. */
  57. bool isValid() const noexcept;
  58. /**
  59. Get width.
  60. */
  61. uint getWidth() const noexcept;
  62. /**
  63. Get height.
  64. */
  65. uint getHeight() const noexcept;
  66. /**
  67. Get size.
  68. */
  69. const Size<uint>& getSize() const noexcept;
  70. /**
  71. Get the raw image data.
  72. */
  73. const char* getRawData() const noexcept;
  74. /**
  75. Draw this image at (0, 0) point.
  76. */
  77. void draw();
  78. /**
  79. Draw this image at (x, y) point.
  80. */
  81. void drawAt(const int x, const int y);
  82. /**
  83. Draw this image at position @a pos.
  84. */
  85. void drawAt(const Point<int>& pos);
  86. /**
  87. TODO document this.
  88. */
  89. ImageBase& operator=(const ImageBase& image) noexcept;
  90. bool operator==(const ImageBase& image) const noexcept;
  91. bool operator!=(const ImageBase& image) const noexcept;
  92. protected:
  93. /** @internal */
  94. virtual void _drawAt(const Point<int>& pos) = 0;
  95. const char* fRawData;
  96. Size<uint> fSize;
  97. };
  98. // -----------------------------------------------------------------------
  99. END_NAMESPACE_DGL
  100. #endif // DGL_IMAGE_HPP_INCLUDED