Irrlicht 3D Engine
IImage.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_IMAGE_H_INCLUDED__
6 #define __I_IMAGE_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "position2d.h"
10 #include "rect.h"
11 #include "SColor.h"
12 
13 namespace irr
14 {
15 namespace video
16 {
17 
19 
22 class IImage : public virtual IReferenceCounted
23 {
24 public:
25 
27 
32  virtual void* lock() = 0;
33 
35 
37  virtual void unlock() = 0;
38 
40  virtual const core::dimension2d<u32>& getDimension() const = 0;
41 
43  virtual u32 getBitsPerPixel() const = 0;
44 
46  virtual u32 getBytesPerPixel() const = 0;
47 
49  virtual u32 getImageDataSizeInBytes() const = 0;
50 
52  virtual u32 getImageDataSizeInPixels() const = 0;
53 
55  virtual SColor getPixel(u32 x, u32 y) const = 0;
56 
58  virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0;
59 
61  virtual ECOLOR_FORMAT getColorFormat() const = 0;
62 
64  virtual u32 getRedMask() const = 0;
65 
67  virtual u32 getGreenMask() const = 0;
68 
70  virtual u32 getBlueMask() const = 0;
71 
73  virtual u32 getAlphaMask() const = 0;
74 
76  virtual u32 getPitch() const =0;
77 
79  virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0;
80 
82  virtual void copyToScaling(IImage* target) =0;
83 
85  virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
86 
88  virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0;
89 
91  virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
92  const core::rect<s32>& sourceRect, const SColor &color,
93  const core::rect<s32>* clipRect = 0) =0;
94 
96  virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0;
97 
99  virtual void fill(const SColor &color) =0;
100 
103  {
104  switch(format)
105  {
106  case ECF_A1R5G5B5:
107  return 16;
108  case ECF_R5G6B5:
109  return 16;
110  case ECF_R8G8B8:
111  return 24;
112  case ECF_A8R8G8B8:
113  return 32;
114  case ECF_R16F:
115  return 16;
116  case ECF_G16R16F:
117  return 32;
118  case ECF_A16B16G16R16F:
119  return 64;
120  case ECF_R32F:
121  return 32;
122  case ECF_G32R32F:
123  return 64;
124  case ECF_A32B32G32R32F:
125  return 128;
126  default:
127  return 0;
128  }
129  }
130 
132 
135  static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
136  {
137  switch(format)
138  {
139  case ECF_A1R5G5B5:
140  case ECF_R5G6B5:
141  case ECF_R8G8B8:
142  case ECF_A8R8G8B8:
143  return false;
144  default:
145  return true;
146  }
147  }
148 
149 };
150 
151 } // end namespace video
152 } // end namespace irr
153 
154 #endif
155 
24 bit color, no alpha channel, but 8 bit for red, green and blue.
Definition: SColor.h:29
static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
get the amount of Bits per Pixel of the given color format
Definition: IImage.h:102
64 bit floating point format using 32 bits for the red channel and 32 bits for the green channel...
Definition: SColor.h:49
virtual SColor getPixel(u32 x, u32 y) const =0
Returns a pixel.
64 bit floating point format 16 bits are used for the red, green, blue and alpha channels.
Definition: SColor.h:43
32 bit floating point format using 32 bits for the red channel.
Definition: SColor.h:46
virtual ECOLOR_FORMAT getColorFormat() const =0
Returns the color format.
virtual void copyToScalingBoxFilter(IImage *target, s32 bias=0, bool blend=false)=0
copies this surface into another, scaling it to fit, appyling a box filter
virtual void fill(const SColor &color)=0
fills the surface with given color
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
Definition: SColor.h:17
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
16 bit floating point format using 16 bits for the red channel.
Definition: SColor.h:37
Interface for software image data.
Definition: IImage.h:22
virtual u32 getGreenMask() const =0
Returns mask for green value of a pixel.
virtual void copyTo(IImage *target, const core::position2d< s32 > &pos=core::position2d< s32 >(0, 0))=0
copies this surface into another
virtual u32 getBlueMask() const =0
Returns mask for blue value of a pixel.
virtual u32 getImageDataSizeInBytes() const =0
Returns image data size in bytes.
signed int s32
32 bit signed variable.
Definition: irrTypes.h:66
virtual void unlock()=0
Unlock function.
128 bit floating point format. 32 bits are used for the red, green, blue and alpha channels...
Definition: SColor.h:52
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:58
16 bit color format used by the software driver.
Definition: SColor.h:23
virtual u32 getImageDataSizeInPixels() const =0
Returns image data size in pixels.
virtual u32 getPitch() const =0
Returns pitch of image.
Class representing a 32 bit ARGB color.
Definition: SColor.h:201
virtual u32 getBytesPerPixel() const =0
Returns bytes per pixel.
Standard 16 bit color format.
Definition: SColor.h:26
virtual void * lock()=0
Lock function. Use this to get a pointer to the image data.
virtual void copyToWithAlpha(IImage *target, const core::position2d< s32 > &pos, const core::rect< s32 > &sourceRect, const SColor &color, const core::rect< s32 > *clipRect=0)=0
copies this surface into another, using the alpha mask and cliprect and a color to add with ...
virtual const core::dimension2d< u32 > & getDimension() const =0
Returns width and height of image data.
Base class of most objects of the Irrlicht Engine.
static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
test if the color format is only viable for RenderTarget textures
Definition: IImage.h:135
Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha...
Definition: SColor.h:32
virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend=false)=0
Sets a pixel.
virtual u32 getRedMask() const =0
Returns mask for red value of a pixel.
virtual u32 getBitsPerPixel() const =0
Returns bits per pixel.
32 bit floating point format using 16 bits for the red channel and 16 bits for the green channel...
Definition: SColor.h:40
virtual u32 getAlphaMask() const =0
Returns mask for alpha value of a pixel.
virtual void copyToScaling(void *target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0)=0
Copies the image into the target, scaling the image to fit.