]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CImage.h
48d45b3b261ba7e21eeff0bcd68fa10be64a203f
[irrlicht.git] / source / Irrlicht / CImage.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_IMAGE_H_INCLUDED__\r
6 #define __C_IMAGE_H_INCLUDED__\r
7 \r
8 #include "IImage.h"\r
9 #include "rect.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace video\r
14 {\r
15 \r
16 //! check sanity of image dimensions to prevent issues later, for use by CImageLoaders\r
17 inline bool checkImageDimensions(u32 width, u32 height)\r
18 {\r
19         // 4 * 23000 * 23000 is just under S32_MAX\r
20         return width <= 23000 && height <= 23000;\r
21 }\r
22 \r
23 //! IImage implementation with a lot of special image operations for\r
24 //! 16 bit A1R5G5B5/32 Bit A8R8G8B8 images, which are used by the SoftwareDevice.\r
25 class CImage : public IImage\r
26 {\r
27 public:\r
28 \r
29         //! constructor from raw image data\r
30         /** \param useForeignMemory: If true, the image will use the data pointer\r
31         directly and own it from now on, which means it will also try to delete [] the\r
32         data when the image will be destructed. If false, the memory will by copied. */\r
33         CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* data,\r
34                 bool ownForeignMemory = true, bool deleteMemory = true);\r
35 \r
36         //! constructor for empty image\r
37         CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size);\r
38 \r
39         //! returns a pixel\r
40         virtual SColor getPixel(u32 x, u32 y) const _IRR_OVERRIDE_;\r
41 \r
42         //! sets a pixel\r
43         virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) _IRR_OVERRIDE_;\r
44 \r
45         //! copies this surface into another, scaling it to fit.\r
46         virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0) _IRR_OVERRIDE_;\r
47 \r
48         //! copies this surface into another, scaling it to fit.\r
49         virtual void copyToScaling(IImage* target) _IRR_OVERRIDE_;\r
50 \r
51         //! copies this surface into another\r
52         virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) _IRR_OVERRIDE_;\r
53 \r
54         //! copies this surface into another\r
55         virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) _IRR_OVERRIDE_;\r
56 \r
57         //! copies this surface into another, using the alpha mask, an cliprect and a color to add with\r
58         virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,\r
59                         const core::rect<s32>& sourceRect, const SColor &color,\r
60                         const core::rect<s32>* clipRect = 0, bool combineAlpha=false) _IRR_OVERRIDE_;\r
61 \r
62         //! copies this surface into another, scaling it to fit, applying a box filter\r
63         virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) _IRR_OVERRIDE_;\r
64 \r
65         //! fills the surface with given color\r
66         virtual void fill(const SColor &color) _IRR_OVERRIDE_;\r
67 \r
68 private:\r
69         inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const;\r
70 };\r
71 \r
72 } // end namespace video\r
73 } // end namespace irr\r
74 \r
75 \r
76 #endif\r
77 \r