Blender  V2.93
imbuf/intern/dds/Image.h
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 #pragma once
31 
32 #include "Color.h"
33 #include "Common.h"
34 
36 class Image {
37  public:
38  enum Format {
41  };
42 
43  Image();
44  ~Image();
45 
46  void allocate(uint w, uint h);
47 #if 0
48  bool load(const char *name);
49 
50  void wrap(void *data, uint w, uint h);
51  void unwrap();
52 #endif
53 
54  uint width() const;
55  uint height() const;
56 
57  const Color32 *scanline(uint h) const;
58  Color32 *scanline(uint h);
59 
60  const Color32 *pixels() const;
61  Color32 *pixels();
62 
63  const Color32 &pixel(uint idx) const;
64  Color32 &pixel(uint idx);
65 
66  const Color32 &pixel(uint x, uint y) const;
67  Color32 &pixel(uint x, uint y);
68 
69  Format format() const;
70  void setFormat(Format f);
71 
72  private:
73  void free();
74 
75  private:
76  uint m_width;
77  uint m_height;
78  Format m_format;
79  Color32 *m_data;
80 };
81 
82 inline const Color32 &Image::pixel(uint x, uint y) const
83 {
84  return pixel(y * width() + x);
85 }
86 
88 {
89  return pixel(y * width() + x);
90 }
unsigned int uint
Definition: BLI_sys_types.h:83
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
Definition: Color.h:33
~Image()
Definition: Image.cpp:39
Format format() const
Definition: Image.cpp:114
void allocate(uint w, uint h)
Definition: Image.cpp:44
const Color32 * pixels() const
Definition: Image.cpp:86
const Color32 & pixel(uint idx) const
Definition: Image.cpp:96
Image()
Definition: Image.cpp:35
uint height() const
Definition: Image.cpp:63
const Color32 * scanline(uint h) const
Definition: Image.cpp:68
void setFormat(Format f)
Definition: Image.cpp:119
uint width() const
Definition: Image.cpp:58
int load(istream &in, Vec3r &v)
Definition: ViewMapIO.cpp:61
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)