Blender
V3.3
source
blender
imbuf
intern
dds
Image.cpp
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2
7
/*
8
* This file is based on a similar file from the NVIDIA texture tools
9
* (http://nvidia-texture-tools.googlecode.com/)
10
*
11
* Original license from NVIDIA follows.
12
*/
13
14
/* This code is in the public domain -- <castanyo@yahoo.es>. */
15
16
#include <
Color.h
>
17
#include <
Image.h
>
18
19
#include <cstdio>
/* printf */
20
21
Image::Image
() :
m_width
(0),
m_height
(0), m_format(Format_RGB),
m_data
(nullptr)
22
{
23
}
24
25
Image::~Image
()
26
{
27
free();
28
}
29
30
void
Image::allocate
(
uint
w
,
uint
h)
31
{
32
free();
33
m_width =
w
;
34
m_height = h;
35
m_data =
new
Color32
[
w
* h];
36
}
37
38
void
Image::free()
39
{
40
delete
[] m_data;
41
m_data =
nullptr
;
42
}
43
44
uint
Image::width
()
const
45
{
46
return
m_width;
47
}
48
49
uint
Image::height
()
const
50
{
51
return
m_height;
52
}
53
54
const
Color32
*
Image::scanline
(
uint
h)
const
55
{
56
if
(h >= m_height) {
57
printf(
"DDS: scanline beyond dimensions of image\n"
);
58
return
m_data;
59
}
60
return
m_data + h * m_width;
61
}
62
63
Color32
*
Image::scanline
(
uint
h)
64
{
65
if
(h >= m_height) {
66
printf(
"DDS: scanline beyond dimensions of image\n"
);
67
return
m_data;
68
}
69
return
m_data + h * m_width;
70
}
71
72
const
Color32
*
Image::pixels
()
const
73
{
74
return
m_data;
75
}
76
77
Color32
*
Image::pixels
()
78
{
79
return
m_data;
80
}
81
82
const
Color32
&
Image::pixel
(
uint
idx)
const
83
{
84
if
(idx >= m_width * m_height) {
85
printf(
"DDS: pixel beyond dimensions of image\n"
);
86
return
m_data[0];
87
}
88
return
m_data[idx];
89
}
90
91
Color32
&
Image::pixel
(
uint
idx)
92
{
93
if
(idx >= m_width * m_height) {
94
printf(
"DDS: pixel beyond dimensions of image\n"
);
95
return
m_data[0];
96
}
97
return
m_data[idx];
98
}
99
100
Image::Format
Image::format
()
const
101
{
102
return
m_format;
103
}
104
105
void
Image::setFormat
(
Image::Format
f)
106
{
107
m_format = f;
108
}
uint
unsigned int uint
Definition:
BLI_sys_types.h:67
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:19
Image::~Image
~Image()
Definition:
Image.cpp:25
Image::format
Format format() const
Definition:
Image.cpp:100
Image::allocate
void allocate(uint w, uint h)
Definition:
Image.cpp:30
Image::Format
Format
Definition:
imbuf/intern/dds/Image.h:24
Image::pixels
const Color32 * pixels() const
Definition:
Image.cpp:72
Image::pixel
const Color32 & pixel(uint idx) const
Definition:
Image.cpp:82
Image::Image
Image()
Definition:
Image.cpp:21
Image::height
uint height() const
Definition:
Image.cpp:49
Image::scanline
const Color32 * scanline(uint h) const
Definition:
Image.cpp:54
Image::setFormat
void setFormat(Format f)
Definition:
Image.cpp:105
Image::width
uint width() const
Definition:
Image.cpp:44
Image.h
Generated on Tue Oct 22 2024 13:18:25 for Blender by
doxygen
1.9.1