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
17 #include "../ImageBase.hpp"
18
19 START_NAMESPACE_DGL
20
21 // -----------------------------------------------------------------------
22
ImageBase()23 ImageBase::ImageBase()
24 : fRawData(nullptr),
25 fSize(0, 0) {}
26
ImageBase(const char * const rawData,const uint width,const uint height)27 ImageBase::ImageBase(const char* const rawData, const uint width, const uint height)
28 : fRawData(rawData),
29 fSize(width, height) {}
30
ImageBase(const char * const rawData,const Size<uint> & size)31 ImageBase::ImageBase(const char* const rawData, const Size<uint>& size)
32 : fRawData(rawData),
33 fSize(size) {}
34
ImageBase(const ImageBase & image)35 ImageBase::ImageBase(const ImageBase& image)
36 : fRawData(image.fRawData),
37 fSize(image.fSize) {}
38
~ImageBase()39 ImageBase::~ImageBase() {}
40
41 // -----------------------------------------------------------------------
42
isValid() const43 bool ImageBase::isValid() const noexcept
44 {
45 return (fRawData != nullptr && fSize.isValid());
46 }
47
getWidth() const48 uint ImageBase::getWidth() const noexcept
49 {
50 return fSize.getWidth();
51 }
52
getHeight() const53 uint ImageBase::getHeight() const noexcept
54 {
55 return fSize.getHeight();
56 }
57
getSize() const58 const Size<uint>& ImageBase::getSize() const noexcept
59 {
60 return fSize;
61 }
62
getRawData() const63 const char* ImageBase::getRawData() const noexcept
64 {
65 return fRawData;
66 }
67
68 // -----------------------------------------------------------------------
69
draw()70 void ImageBase::draw()
71 {
72 _drawAt(Point<int>());
73 }
74
drawAt(const int x,const int y)75 void ImageBase::drawAt(const int x, const int y)
76 {
77 _drawAt(Point<int>(x, y));
78 }
79
drawAt(const Point<int> & pos)80 void ImageBase::drawAt(const Point<int>& pos)
81 {
82 _drawAt(pos);
83 }
84
85 // -----------------------------------------------------------------------
86
operator =(const ImageBase & image)87 ImageBase& ImageBase::operator=(const ImageBase& image) noexcept
88 {
89 fRawData = image.fRawData;
90 fSize = image.fSize;
91 return *this;
92 }
93
operator ==(const ImageBase & image) const94 bool ImageBase::operator==(const ImageBase& image) const noexcept
95 {
96 return (fRawData == image.fRawData && fSize == image.fSize);
97 }
98
operator !=(const ImageBase & image) const99 bool ImageBase::operator!=(const ImageBase& image) const noexcept
100 {
101 return !operator==(image);
102 }
103
104 // -----------------------------------------------------------------------
105
106 END_NAMESPACE_DGL
107