Dusk Audio Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
dgl
ImageBase.hpp
1
/*
2
* DISTRHO Plugin Framework (DPF)
3
* Copyright (C) 2012-2021 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
#ifndef DGL_IMAGE_BASE_HPP_INCLUDED
18
#define DGL_IMAGE_BASE_HPP_INCLUDED
19
20
#include "Geometry.hpp"
21
22
START_NAMESPACE_DGL
23
24
// --------------------------------------------------------------------------------------------------------------------
25
26
enum
ImageFormat {
27
kImageFormatNull,
28
kImageFormatGrayscale,
29
kImageFormatBGR,
30
kImageFormatBGRA,
31
kImageFormatRGB,
32
kImageFormatRGBA,
33
};
34
35
/**
36
Base DGL Image class.
37
38
This is an Image class that handles raw image data in pixels.
39
It is an abstract class that provides the common methods to build on top.
40
Cairo and OpenGL Image classes are based upon this one.
41
42
@see CairoImage, OpenGLImage
43
*/
44
class
ImageBase
45
{
46
protected
:
47
/**
48
Constructor for a null Image.
49
*/
50
ImageBase
();
51
52
/**
53
Constructor using raw image data.
54
@note @a rawData must remain valid for the lifetime of this Image.
55
*/
56
ImageBase
(
const
char
* rawData, uint width, uint height, ImageFormat format);
57
58
/**
59
Constructor using raw image data.
60
@note @a rawData must remain valid for the lifetime of this Image.
61
*/
62
ImageBase
(
const
char
* rawData,
const
Size<uint>
& size, ImageFormat format);
63
64
/**
65
Constructor using another image data.
66
*/
67
ImageBase
(
const
ImageBase
& image);
68
69
public
:
70
/**
71
Destructor.
72
*/
73
virtual
~ImageBase
();
74
75
/**
76
Check if this image is valid.
77
*/
78
bool
isValid
() const noexcept;
79
80
/**
81
Check if this image is not valid.
82
*/
83
bool
isInvalid
() const noexcept;
84
85
/**
86
Get width.
87
*/
88
uint
getWidth
() const noexcept;
89
90
/**
91
Get height.
92
*/
93
uint
getHeight
() const noexcept;
94
95
/**
96
Get size.
97
*/
98
const
Size
<uint>&
getSize
() const noexcept;
99
100
/**
101
Get the raw image data.
102
*/
103
const
char
*
getRawData
() const noexcept;
104
105
/**
106
Get the image format.
107
*/
108
ImageFormat
getFormat
() const noexcept;
109
110
/**
111
Load image data from memory.
112
@note @a rawData must remain valid for the lifetime of this Image.
113
*/
114
void
loadFromMemory
(const
char
* rawData, uint width, uint height, ImageFormat format = kImageFormatBGRA) noexcept;
115
116
/**
117
Load image data from memory.
118
@note @a rawData must remain valid for the lifetime of this Image.
119
*/
120
virtual
void
loadFromMemory
(const
char
* rawData,
121
const
Size
<uint>& size,
122
ImageFormat format = kImageFormatBGRA) noexcept;
123
124
/**
125
Draw this image at (0, 0) point using the current OpenGL context.
126
*/
127
void
draw
(const
GraphicsContext
& context);
128
129
/**
130
Draw this image at (x, y) point using the current OpenGL context.
131
*/
132
void
drawAt
(const
GraphicsContext
& context,
int
x,
int
y);
133
134
/**
135
Draw this image at position @a pos using the current OpenGL context.
136
*/
137
virtual
void
drawAt
(const
GraphicsContext
& context, const
Point
<
int
>& pos) = 0;
138
139
/**
140
TODO document this.
141
*/
142
ImageBase
& operator=(const
ImageBase
& image) noexcept;
143
bool
operator==(const
ImageBase
& image) const noexcept;
144
bool
operator!=(const
ImageBase
& image) const noexcept;
145
146
protected:
147
const
char
* rawData;
148
Size
<uint> size;
149
ImageFormat format;
150
};
151
152
// --------------------------------------------------------------------------------------------------------------------
153
154
END_NAMESPACE_DGL
155
156
#endif
// DGL_IMAGE_HPP_INCLUDED
ImageBase::drawAt
void drawAt(const GraphicsContext &context, int x, int y)
ImageBase::ImageBase
ImageBase()
ImageBase::loadFromMemory
void loadFromMemory(const char *rawData, uint width, uint height, ImageFormat format=kImageFormatBGRA) noexcept
ImageBase::~ImageBase
virtual ~ImageBase()
ImageBase::ImageBase
ImageBase(const char *rawData, uint width, uint height, ImageFormat format)
ImageBase::getFormat
ImageFormat getFormat() const noexcept
ImageBase::getRawData
const char * getRawData() const noexcept
ImageBase::ImageBase
ImageBase(const ImageBase &image)
ImageBase::getSize
const Size< uint > & getSize() const noexcept
ImageBase::getWidth
uint getWidth() const noexcept
ImageBase::isInvalid
bool isInvalid() const noexcept
ImageBase::draw
void draw(const GraphicsContext &context)
ImageBase::ImageBase
ImageBase(const char *rawData, const Size< uint > &size, ImageFormat format)
ImageBase::isValid
bool isValid() const noexcept
ImageBase::getHeight
uint getHeight() const noexcept
Point
Definition
Geometry.hpp:41
Size
Definition
Geometry.hpp:133
GraphicsContext
Definition
Base.hpp:287
Generated by
1.18.0