]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CColorConverter.h
Merging r5975 through r6036 from trunk to ogl-es branch.
[irrlicht.git] / source / Irrlicht / CColorConverter.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_COLOR_CONVERTER_H_INCLUDED__\r
6 #define __C_COLOR_CONVERTER_H_INCLUDED__\r
7 \r
8 #include "irrTypes.h"\r
9 #include "IImage.h"\r
10 \r
11 namespace irr\r
12 {\r
13 namespace video\r
14 {\r
15 \r
16 class CColorConverter\r
17 {\r
18 public:\r
19 \r
20         //! converts a monochrome bitmap to A1R5G5B5\r
21         static void convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false);\r
22 \r
23         //! converts a 4 bit palettized image to A1R5G5B5\r
24         static void convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false);\r
25 \r
26         //! converts a 8 bit palettized image to A1R5G5B5\r
27         static void convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false);\r
28 \r
29         //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8\r
30         static void convert8BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad = 0, bool flip=false);\r
31 \r
32         //! converts a 8 bit palettized or non palettized image (A8) into A8R8G8B8\r
33         static void convert8BitTo32Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad = 0, bool flip=false);\r
34 \r
35         //! converts R8G8B8 16 bit data to A1R5G5B5 data\r
36         static void convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false);\r
37 \r
38         //! copies R8G8B8 24 bit data to 24 data, and flips and\r
39         //! mirrors the image during the process.\r
40         static void convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad=0, bool flip=false, bool bgr=false);\r
41 \r
42         //! Resizes the surface to a new size and converts it at the same time\r
43         //! to an A8R8G8B8 format, returning the pointer to the new buffer.\r
44         static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight);\r
45 \r
46         //! copies X8R8G8B8 32 bit data, and flips and\r
47         //! mirrors the image during the process.\r
48         static void convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip=false);\r
49 \r
50 \r
51         //! Functions for converting one image format to another efficiently\r
52         //! and hopefully correctly.\r
53         //! Note that the format descriptions refer to the ECOLOR_FORMAT's and not to memory layout.\r
54         //! Reasons for that go back to DX9 naming which tended to flip 32-bit and 16-bit byte orders so ARGB usually means BGRA.\r
55         //!\r
56         //! \param sP pointer to source pixel data\r
57         //! \param sN number of source pixels to copy\r
58         //! \param dP pointer to destination data buffer. must be big enough\r
59         //! to hold sN pixels in the output format.\r
60         static void convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP);\r
61         static void convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP);\r
62         static void convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
63         static void convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP);\r
64         static void convert_A1R5G5B5toR5G5B5A1(const void* sP, s32 sN, void* dP);\r
65         static void convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP);\r
66 \r
67         static void convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP);\r
68         static void convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP);\r
69         static void convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
70         static void convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP);\r
71         static void convert_A8R8G8B8toA1B5G5R5(const void* sP, s32 sN, void* dP);\r
72         static void convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP);\r
73 \r
74         static void convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP);\r
75         static void convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP);\r
76         static void convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
77         static void convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP);\r
78         static void convert_R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP);\r
79         static void convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP);\r
80         static void convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
81         static void convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
82         static void convert_A8R8G8B8toR8G8B8A8(const void* sP, s32 sN, void* dP);\r
83         static void convert_A8R8G8B8toA8B8G8R8(const void* sP, s32 sN, void* dP);\r
84 \r
85         static void convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP);\r
86         static void convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP);\r
87         static void convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP);\r
88         static void convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP);\r
89         static void convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP);\r
90         static void convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN,\r
91                                 void* dP, ECOLOR_FORMAT dF);\r
92         // Check if convert_viaFormat is usable\r
93         static bool canConvertFormat(ECOLOR_FORMAT sourceFormat, ECOLOR_FORMAT destFormat);\r
94 };\r
95 \r
96 \r
97 } // end namespace video\r
98 } // end namespace irr\r
99 \r
100 #endif\r
101 \r