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.

107 lines
2.7KB

  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. #include "../ImageBase.hpp"
  17. START_NAMESPACE_DGL
  18. // -----------------------------------------------------------------------
  19. ImageBase::ImageBase()
  20. : fRawData(nullptr),
  21. fSize(0, 0) {}
  22. ImageBase::ImageBase(const char* const rawData, const uint width, const uint height)
  23. : fRawData(rawData),
  24. fSize(width, height) {}
  25. ImageBase::ImageBase(const char* const rawData, const Size<uint>& size)
  26. : fRawData(rawData),
  27. fSize(size) {}
  28. ImageBase::ImageBase(const ImageBase& image)
  29. : fRawData(image.fRawData),
  30. fSize(image.fSize) {}
  31. ImageBase::~ImageBase() {}
  32. // -----------------------------------------------------------------------
  33. bool ImageBase::isValid() const noexcept
  34. {
  35. return (fRawData != nullptr && fSize.isValid());
  36. }
  37. uint ImageBase::getWidth() const noexcept
  38. {
  39. return fSize.getWidth();
  40. }
  41. uint ImageBase::getHeight() const noexcept
  42. {
  43. return fSize.getHeight();
  44. }
  45. const Size<uint>& ImageBase::getSize() const noexcept
  46. {
  47. return fSize;
  48. }
  49. const char* ImageBase::getRawData() const noexcept
  50. {
  51. return fRawData;
  52. }
  53. // -----------------------------------------------------------------------
  54. void ImageBase::draw()
  55. {
  56. _drawAt(Point<int>());
  57. }
  58. void ImageBase::drawAt(const int x, const int y)
  59. {
  60. _drawAt(Point<int>(x, y));
  61. }
  62. void ImageBase::drawAt(const Point<int>& pos)
  63. {
  64. _drawAt(pos);
  65. }
  66. // -----------------------------------------------------------------------
  67. ImageBase& ImageBase::operator=(const ImageBase& image) noexcept
  68. {
  69. fRawData = image.fRawData;
  70. fSize = image.fSize;
  71. return *this;
  72. }
  73. bool ImageBase::operator==(const ImageBase& image) const noexcept
  74. {
  75. return (fRawData == image.fRawData && fSize == image.fSize);
  76. }
  77. bool ImageBase::operator!=(const ImageBase& image) const noexcept
  78. {
  79. return !operator==(image);
  80. }
  81. // -----------------------------------------------------------------------
  82. END_NAMESPACE_DGL