2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
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.
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.
17 #include "../ImageBase.hpp"
21 // --------------------------------------------------------------------------------------------------------------------
22 // protected constructors
24 ImageBase::ImageBase()
27 format(kImageFormatNull
) {}
29 ImageBase::ImageBase(const char* const rdata
, const uint width
, const uint height
, const ImageFormat fmt
)
34 ImageBase::ImageBase(const char* const rdata
, const Size
<uint
>& s
, const ImageFormat fmt
)
39 ImageBase::ImageBase(const ImageBase
& image
)
40 : rawData(image
.rawData
),
42 format(image
.format
) {}
44 // --------------------------------------------------------------------------------------------------------------------
47 ImageBase::~ImageBase() {}
49 bool ImageBase::isValid() const noexcept
51 return (rawData
!= nullptr && size
.isValid());
54 bool ImageBase::isInvalid() const noexcept
56 return (rawData
== nullptr || size
.isInvalid());
59 uint
ImageBase::getWidth() const noexcept
61 return size
.getWidth();
64 uint
ImageBase::getHeight() const noexcept
66 return size
.getHeight();
69 const Size
<uint
>& ImageBase::getSize() const noexcept
74 const char* ImageBase::getRawData() const noexcept
79 ImageFormat
ImageBase::getFormat() const noexcept
84 void ImageBase::loadFromMemory(const char* const rdata
,
87 const ImageFormat fmt
) noexcept
89 loadFromMemory(rdata
, Size
<uint
>(width
, height
), fmt
);
92 void ImageBase::loadFromMemory(const char* const rdata
, const Size
<uint
>& s
, const ImageFormat fmt
) noexcept
99 void ImageBase::draw(const GraphicsContext
& context
)
101 drawAt(context
, Point
<int>(0, 0));
104 void ImageBase::drawAt(const GraphicsContext
& context
, const int x
, const int y
)
106 drawAt(context
, Point
<int>(x
, y
));
109 // --------------------------------------------------------------------------------------------------------------------
112 ImageBase
& ImageBase::operator=(const ImageBase
& image
) noexcept
114 rawData
= image
.rawData
;
116 format
= image
.format
;
120 bool ImageBase::operator==(const ImageBase
& image
) const noexcept
122 return (rawData
== image
.rawData
&& size
== image
.size
&& format
== image
.format
);
125 bool ImageBase::operator!=(const ImageBase
& image
) const noexcept
127 return !operator==(image
);
130 // --------------------------------------------------------------------------------------------------------------------