diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CImage.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CImage.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CImage.h b/libraries/irrlicht-1.8/source/Irrlicht/CImage.h new file mode 100644 index 0000000..82b34c7 --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/CImage.h | |||
@@ -0,0 +1,127 @@ | |||
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 __C_IMAGE_H_INCLUDED__ | ||
6 | #define __C_IMAGE_H_INCLUDED__ | ||
7 | |||
8 | #include "IImage.h" | ||
9 | #include "rect.h" | ||
10 | |||
11 | namespace irr | ||
12 | { | ||
13 | namespace video | ||
14 | { | ||
15 | |||
16 | //! IImage implementation with a lot of special image operations for | ||
17 | //! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice. | ||
18 | class CImage : public IImage | ||
19 | { | ||
20 | public: | ||
21 | |||
22 | //! constructor from raw image data | ||
23 | /** \param useForeignMemory: If true, the image will use the data pointer | ||
24 | directly and own it from now on, which means it will also try to delete [] the | ||
25 | data when the image will be destructed. If false, the memory will by copied. */ | ||
26 | CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, | ||
27 | void* data, bool ownForeignMemory=true, bool deleteMemory = true); | ||
28 | |||
29 | //! constructor for empty image | ||
30 | CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size); | ||
31 | |||
32 | //! destructor | ||
33 | virtual ~CImage(); | ||
34 | |||
35 | //! Lock function. | ||
36 | virtual void* lock() | ||
37 | { | ||
38 | return Data; | ||
39 | } | ||
40 | |||
41 | //! Unlock function. | ||
42 | virtual void unlock() {} | ||
43 | |||
44 | //! Returns width and height of image data. | ||
45 | virtual const core::dimension2d<u32>& getDimension() const; | ||
46 | |||
47 | //! Returns bits per pixel. | ||
48 | virtual u32 getBitsPerPixel() const; | ||
49 | |||
50 | //! Returns bytes per pixel | ||
51 | virtual u32 getBytesPerPixel() const; | ||
52 | |||
53 | //! Returns image data size in bytes | ||
54 | virtual u32 getImageDataSizeInBytes() const; | ||
55 | |||
56 | //! Returns image data size in pixels | ||
57 | virtual u32 getImageDataSizeInPixels() const; | ||
58 | |||
59 | //! returns mask for red value of a pixel | ||
60 | virtual u32 getRedMask() const; | ||
61 | |||
62 | //! returns mask for green value of a pixel | ||
63 | virtual u32 getGreenMask() const; | ||
64 | |||
65 | //! returns mask for blue value of a pixel | ||
66 | virtual u32 getBlueMask() const; | ||
67 | |||
68 | //! returns mask for alpha value of a pixel | ||
69 | virtual u32 getAlphaMask() const; | ||
70 | |||
71 | //! returns a pixel | ||
72 | virtual SColor getPixel(u32 x, u32 y) const; | ||
73 | |||
74 | //! sets a pixel | ||
75 | virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ); | ||
76 | |||
77 | //! returns the color format | ||
78 | virtual ECOLOR_FORMAT getColorFormat() const; | ||
79 | |||
80 | //! returns pitch of image | ||
81 | virtual u32 getPitch() const { return Pitch; } | ||
82 | |||
83 | //! copies this surface into another, scaling it to fit. | ||
84 | virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0); | ||
85 | |||
86 | //! copies this surface into another, scaling it to fit. | ||
87 | virtual void copyToScaling(IImage* target); | ||
88 | |||
89 | //! copies this surface into another | ||
90 | virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)); | ||
91 | |||
92 | //! copies this surface into another | ||
93 | virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0); | ||
94 | |||
95 | //! copies this surface into another, using the alpha mask, an cliprect and a color to add with | ||
96 | virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, | ||
97 | const core::rect<s32>& sourceRect, const SColor &color, | ||
98 | const core::rect<s32>* clipRect = 0); | ||
99 | |||
100 | //! copies this surface into another, scaling it to fit, appyling a box filter | ||
101 | virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false); | ||
102 | |||
103 | //! fills the surface with given color | ||
104 | virtual void fill(const SColor &color); | ||
105 | |||
106 | private: | ||
107 | |||
108 | //! assumes format and size has been set and creates the rest | ||
109 | void initData(); | ||
110 | |||
111 | inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const; | ||
112 | |||
113 | u8* Data; | ||
114 | core::dimension2d<u32> Size; | ||
115 | u32 BytesPerPixel; | ||
116 | u32 Pitch; | ||
117 | ECOLOR_FORMAT Format; | ||
118 | |||
119 | bool DeleteMemory; | ||
120 | }; | ||
121 | |||
122 | } // end namespace video | ||
123 | } // end namespace irr | ||
124 | |||
125 | |||
126 | #endif | ||
127 | |||