Blender
V2.93
source
blender
imbuf
intern
dds
Image.cpp
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*/
16
21
/*
22
* This file is based on a similar file from the NVIDIA texture tools
23
* (http://nvidia-texture-tools.googlecode.com/)
24
*
25
* Original license from NVIDIA follows.
26
*/
27
28
/* This code is in the public domain -- <castanyo@yahoo.es>. */
29
30
#include <
Color.h
>
31
#include <
Image.h
>
32
33
#include <cstdio>
/* printf */
34
35
Image::Image
() :
m_width
(0),
m_height
(0), m_format(Format_RGB),
m_data
(nullptr)
36
{
37
}
38
39
Image::~Image
()
40
{
41
free();
42
}
43
44
void
Image::allocate
(
uint
w
,
uint
h)
45
{
46
free();
47
m_width =
w
;
48
m_height = h;
49
m_data =
new
Color32
[
w
* h];
50
}
51
52
void
Image::free()
53
{
54
delete
[] m_data;
55
m_data =
nullptr
;
56
}
57
58
uint
Image::width
()
const
59
{
60
return
m_width;
61
}
62
63
uint
Image::height
()
const
64
{
65
return
m_height;
66
}
67
68
const
Color32
*
Image::scanline
(
uint
h)
const
69
{
70
if
(h >= m_height) {
71
printf(
"DDS: scanline beyond dimensions of image\n"
);
72
return
m_data;
73
}
74
return
m_data + h * m_width;
75
}
76
77
Color32
*
Image::scanline
(
uint
h)
78
{
79
if
(h >= m_height) {
80
printf(
"DDS: scanline beyond dimensions of image\n"
);
81
return
m_data;
82
}
83
return
m_data + h * m_width;
84
}
85
86
const
Color32
*
Image::pixels
()
const
87
{
88
return
m_data;
89
}
90
91
Color32
*
Image::pixels
()
92
{
93
return
m_data;
94
}
95
96
const
Color32
&
Image::pixel
(
uint
idx)
const
97
{
98
if
(idx >= m_width * m_height) {
99
printf(
"DDS: pixel beyond dimensions of image\n"
);
100
return
m_data[0];
101
}
102
return
m_data[idx];
103
}
104
105
Color32
&
Image::pixel
(
uint
idx)
106
{
107
if
(idx >= m_width * m_height) {
108
printf(
"DDS: pixel beyond dimensions of image\n"
);
109
return
m_data[0];
110
}
111
return
m_data[idx];
112
}
113
114
Image::Format
Image::format
()
const
115
{
116
return
m_format;
117
}
118
119
void
Image::setFormat
(
Image::Format
f)
120
{
121
m_format = f;
122
}
uint
unsigned int uint
Definition:
BLI_sys_types.h:83
Color.h
m_height
btScalar m_height
Definition:
btConeShape.h:29
m_width
btScalar m_width
Definition:
btHeightfieldTerrainShape.h:92
m_data
btAlignedObjectArray< btScalar > m_data
Definition:
btMultiBodyConstraint.h:80
w
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition:
btQuadWord.h:119
Color32
Definition:
Color.h:33
Image::~Image
~Image()
Definition:
Image.cpp:39
Image::format
Format format() const
Definition:
Image.cpp:114
Image::allocate
void allocate(uint w, uint h)
Definition:
Image.cpp:44
Image::Format
Format
Definition:
imbuf/intern/dds/Image.h:38
Image::pixels
const Color32 * pixels() const
Definition:
Image.cpp:86
Image::pixel
const Color32 & pixel(uint idx) const
Definition:
Image.cpp:96
Image::Image
Image()
Definition:
Image.cpp:35
Image::height
uint height() const
Definition:
Image.cpp:63
Image::scanline
const Color32 * scanline(uint h) const
Definition:
Image.cpp:68
Image::setFormat
void setFormat(Format f)
Definition:
Image.cpp:119
Image::width
uint width() const
Definition:
Image.cpp:58
Image.h
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1