1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef _PixelFormat_H__ |
---|
30 | #define _PixelFormat_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | #include "OgreCommon.h" |
---|
34 | |
---|
35 | namespace Ogre { |
---|
36 | /** The pixel format used for images, textures, and render surfaces */ |
---|
37 | enum PixelFormat |
---|
38 | { |
---|
39 | /// Unknown pixel format. |
---|
40 | PF_UNKNOWN = 0, |
---|
41 | /// 8-bit pixel format, all bits luminace. |
---|
42 | PF_L8 = 1, |
---|
43 | PF_BYTE_L = PF_L8, |
---|
44 | /// 16-bit pixel format, all bits luminace. |
---|
45 | PF_L16 = 2, |
---|
46 | PF_SHORT_L = PF_L16, |
---|
47 | /// 8-bit pixel format, all bits alpha. |
---|
48 | PF_A8 = 3, |
---|
49 | PF_BYTE_A = PF_A8, |
---|
50 | /// 8-bit pixel format, 4 bits alpha, 4 bits luminace. |
---|
51 | PF_A4L4 = 4, |
---|
52 | /// 2 byte pixel format, 1 byte luminance, 1 byte alpha |
---|
53 | PF_BYTE_LA = 5, |
---|
54 | /// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue. |
---|
55 | PF_R5G6B5 = 6, |
---|
56 | /// 16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue. |
---|
57 | PF_B5G6R5 = 7, |
---|
58 | /// 8-bit pixel format, 2 bits blue, 3 bits green, 3 bits red. |
---|
59 | PF_R3G3B2 = 31, |
---|
60 | /// 16-bit pixel format, 4 bits for alpha, red, green and blue. |
---|
61 | PF_A4R4G4B4 = 8, |
---|
62 | /// 16-bit pixel format, 5 bits for blue, green, red and 1 for alpha. |
---|
63 | PF_A1R5G5B5 = 9, |
---|
64 | /// 24-bit pixel format, 8 bits for red, green and blue. |
---|
65 | PF_R8G8B8 = 10, |
---|
66 | /// 24-bit pixel format, 8 bits for blue, green and red. |
---|
67 | PF_B8G8R8 = 11, |
---|
68 | /// 32-bit pixel format, 8 bits for alpha, red, green and blue. |
---|
69 | PF_A8R8G8B8 = 12, |
---|
70 | /// 32-bit pixel format, 8 bits for blue, green, red and alpha. |
---|
71 | PF_A8B8G8R8 = 13, |
---|
72 | /// 32-bit pixel format, 8 bits for blue, green, red and alpha. |
---|
73 | PF_B8G8R8A8 = 14, |
---|
74 | /// 32-bit pixel format, 8 bits for red, green, blue and alpha. |
---|
75 | PF_R8G8B8A8 = 28, |
---|
76 | /// 32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue |
---|
77 | /// like PF_A8R8G8B8, but alpha will get discarded |
---|
78 | PF_X8R8G8B8 = 26, |
---|
79 | /// 32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red |
---|
80 | /// like PF_A8B8G8R8, but alpha will get discarded |
---|
81 | PF_X8B8G8R8 = 27, |
---|
82 | #if OGRE_ENDIAN == OGRE_ENDIAN_BIG |
---|
83 | /// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue |
---|
84 | PF_BYTE_RGB = PF_R8G8B8, |
---|
85 | /// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red |
---|
86 | PF_BYTE_BGR = PF_B8G8R8, |
---|
87 | /// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha |
---|
88 | PF_BYTE_BGRA = PF_B8G8R8A8, |
---|
89 | /// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha |
---|
90 | PF_BYTE_RGBA = PF_R8G8B8A8, |
---|
91 | #else |
---|
92 | /// 3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue |
---|
93 | PF_BYTE_RGB = PF_B8G8R8, |
---|
94 | /// 3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red |
---|
95 | PF_BYTE_BGR = PF_R8G8B8, |
---|
96 | /// 4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha |
---|
97 | PF_BYTE_BGRA = PF_A8R8G8B8, |
---|
98 | /// 4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha |
---|
99 | PF_BYTE_RGBA = PF_A8B8G8R8, |
---|
100 | #endif |
---|
101 | /// 32-bit pixel format, 2 bits for alpha, 10 bits for red, green and blue. |
---|
102 | PF_A2R10G10B10 = 15, |
---|
103 | /// 32-bit pixel format, 10 bits for blue, green and red, 2 bits for alpha. |
---|
104 | PF_A2B10G10R10 = 16, |
---|
105 | /// DDS (DirectDraw Surface) DXT1 format |
---|
106 | PF_DXT1 = 17, |
---|
107 | /// DDS (DirectDraw Surface) DXT2 format |
---|
108 | PF_DXT2 = 18, |
---|
109 | /// DDS (DirectDraw Surface) DXT3 format |
---|
110 | PF_DXT3 = 19, |
---|
111 | /// DDS (DirectDraw Surface) DXT4 format |
---|
112 | PF_DXT4 = 20, |
---|
113 | /// DDS (DirectDraw Surface) DXT5 format |
---|
114 | PF_DXT5 = 21, |
---|
115 | // 16-bit pixel format, 16 bits (float) for red |
---|
116 | PF_FLOAT16_R = 32, |
---|
117 | // 48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue |
---|
118 | PF_FLOAT16_RGB = 22, |
---|
119 | // 64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue, 16 bits (float) for alpha |
---|
120 | PF_FLOAT16_RGBA = 23, |
---|
121 | // 16-bit pixel format, 16 bits (float) for red |
---|
122 | PF_FLOAT32_R = 33, |
---|
123 | // 96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue |
---|
124 | PF_FLOAT32_RGB = 24, |
---|
125 | // 128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue, 32 bits (float) for alpha |
---|
126 | PF_FLOAT32_RGBA = 25, |
---|
127 | // 32-bit, 2-channel s10e5 floating point pixel format, 16-bit green, 16-bit red |
---|
128 | PF_FLOAT16_GR = 35, |
---|
129 | // 64-bit, 2-channel floating point pixel format, 32-bit green, 32-bit red |
---|
130 | PF_FLOAT32_GR = 36, |
---|
131 | // Depth texture format |
---|
132 | PF_DEPTH = 29, |
---|
133 | // 64-bit pixel format, 16 bits for red, green, blue and alpha |
---|
134 | PF_SHORT_RGBA = 30, |
---|
135 | // 32-bit pixel format, 16-bit green, 16-bit red |
---|
136 | PF_SHORT_GR = 34, |
---|
137 | // 48-bit pixel format, 16 bits for red, green and blue |
---|
138 | PF_SHORT_RGB = 37, |
---|
139 | // Number of pixel formats currently defined |
---|
140 | PF_COUNT = 38 |
---|
141 | }; |
---|
142 | |
---|
143 | /** |
---|
144 | * Flags defining some on/off properties of pixel formats |
---|
145 | */ |
---|
146 | enum PixelFormatFlags { |
---|
147 | // This format has an alpha channel |
---|
148 | PFF_HASALPHA = 0x00000001, |
---|
149 | // This format is compressed. This invalidates the values in elemBytes, |
---|
150 | // elemBits and the bit counts as these might not be fixed in a compressed format. |
---|
151 | PFF_COMPRESSED = 0x00000002, |
---|
152 | // This is a floating point format |
---|
153 | PFF_FLOAT = 0x00000004, |
---|
154 | // This is a depth format (for depth textures) |
---|
155 | PFF_DEPTH = 0x00000008, |
---|
156 | // Format is in native endian. Generally true for the 16, 24 and 32 bits |
---|
157 | // formats which can be represented as machine integers. |
---|
158 | PFF_NATIVEENDIAN = 0x00000010, |
---|
159 | // This is an intensity format instead of a RGB one. The luminance |
---|
160 | // replaces R,G and B. (but not A) |
---|
161 | PFF_LUMINANCE = 0x00000020 |
---|
162 | }; |
---|
163 | |
---|
164 | /** Pixel component format */ |
---|
165 | enum PixelComponentType |
---|
166 | { |
---|
167 | PCT_BYTE = 0, /// Byte per component (8 bit fixed 0.0..1.0) |
---|
168 | PCT_SHORT = 1, /// Short per component (16 bit fixed 0.0..1.0)) |
---|
169 | PCT_FLOAT16 = 2, /// 16 bit float per component |
---|
170 | PCT_FLOAT32 = 3, /// 32 bit float per component |
---|
171 | PCT_COUNT = 4 /// Number of pixel types |
---|
172 | }; |
---|
173 | |
---|
174 | /** A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory. |
---|
175 | In case of a rectangle, depth must be 1. |
---|
176 | Pixels are stored as a succession of "depth" slices, each containing "height" rows of |
---|
177 | "width" pixels. |
---|
178 | */ |
---|
179 | class _OgreExport PixelBox: public Box { |
---|
180 | public: |
---|
181 | /// Parameter constructor for setting the members manually |
---|
182 | PixelBox() {} |
---|
183 | /** Constructor providing extents in the form of a Box object. This constructor |
---|
184 | assumes the pixel data is laid out consecutively in memory. (this |
---|
185 | means row after row, slice after slice, with no space in between) |
---|
186 | @param extents Extents of the region defined by data |
---|
187 | @param pixelFormat Format of this buffer |
---|
188 | @param pixelData Pointer to the actual data |
---|
189 | */ |
---|
190 | PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0): |
---|
191 | Box(extents), data(pixelData), format(pixelFormat) |
---|
192 | { |
---|
193 | setConsecutive(); |
---|
194 | } |
---|
195 | /** Constructor providing width, height and depth. This constructor |
---|
196 | assumes the pixel data is laid out consecutively in memory. (this |
---|
197 | means row after row, slice after slice, with no space in between) |
---|
198 | @param width Width of the region |
---|
199 | @param height Height of the region |
---|
200 | @param depth Depth of the region |
---|
201 | @param pixelFormat Format of this buffer |
---|
202 | @param pixelData Pointer to the actual data |
---|
203 | */ |
---|
204 | PixelBox(size_t width, size_t height, size_t depth, PixelFormat pixelFormat, void *pixelData=0): |
---|
205 | Box(0, 0, 0, width, height, depth), |
---|
206 | data(pixelData), format(pixelFormat) |
---|
207 | { |
---|
208 | setConsecutive(); |
---|
209 | } |
---|
210 | |
---|
211 | /// The data pointer |
---|
212 | void *data; |
---|
213 | /// The pixel format |
---|
214 | PixelFormat format; |
---|
215 | /** Number of elements between the leftmost pixel of one row and the left |
---|
216 | pixel of the next. This value must always be equal to getWidth() (consecutive) |
---|
217 | for compressed formats. |
---|
218 | */ |
---|
219 | size_t rowPitch; |
---|
220 | /** Number of elements between the top left pixel of one (depth) slice and |
---|
221 | the top left pixel of the next. This can be a negative value. Must be a multiple of |
---|
222 | rowPitch. This value must always be equal to getWidth()*getHeight() (consecutive) |
---|
223 | for compressed formats. |
---|
224 | */ |
---|
225 | size_t slicePitch; |
---|
226 | |
---|
227 | /** Set the rowPitch and slicePitch so that the buffer is laid out consecutive |
---|
228 | in memory. |
---|
229 | */ |
---|
230 | void setConsecutive() |
---|
231 | { |
---|
232 | rowPitch = getWidth(); |
---|
233 | slicePitch = getWidth()*getHeight(); |
---|
234 | } |
---|
235 | /** Get the number of elements between one past the rightmost pixel of |
---|
236 | one row and the leftmost pixel of the next row. (IE this is zero if rows |
---|
237 | are consecutive). |
---|
238 | */ |
---|
239 | size_t getRowSkip() const { return rowPitch - getWidth(); } |
---|
240 | /** Get the number of elements between one past the right bottom pixel of |
---|
241 | one slice and the left top pixel of the next slice. (IE this is zero if slices |
---|
242 | are consecutive). |
---|
243 | */ |
---|
244 | size_t getSliceSkip() const { return slicePitch - (getHeight() * rowPitch); } |
---|
245 | |
---|
246 | /** Return whether this buffer is laid out consecutive in memory (ie the pitches |
---|
247 | are equal to the dimensions) |
---|
248 | */ |
---|
249 | bool isConsecutive() const |
---|
250 | { |
---|
251 | return rowPitch == getWidth() && slicePitch == getWidth()*getHeight(); |
---|
252 | } |
---|
253 | /** Return the size (in bytes) this image would take if it was |
---|
254 | laid out consecutive in memory |
---|
255 | */ |
---|
256 | size_t getConsecutiveSize() const; |
---|
257 | /** Return a subvolume of this PixelBox. |
---|
258 | @param def Defines the bounds of the subregion to return |
---|
259 | @returns A pixel box describing the region and the data in it |
---|
260 | @remarks This function does not copy any data, it just returns |
---|
261 | a PixelBox object with a data pointer pointing somewhere inside |
---|
262 | the data of object. |
---|
263 | @throws Exception(ERR_INVALIDPARAMS) if def is not fully contained |
---|
264 | */ |
---|
265 | PixelBox getSubVolume(const Box &def) const; |
---|
266 | }; |
---|
267 | |
---|
268 | |
---|
269 | /** |
---|
270 | * Some utility functions for packing and unpacking pixel data |
---|
271 | */ |
---|
272 | class _OgreExport PixelUtil { |
---|
273 | public: |
---|
274 | /** Returns the size in bytes of an element of the given pixel format. |
---|
275 | @returns |
---|
276 | The size in bytes of an element. See Remarks. |
---|
277 | @remarks |
---|
278 | Passing PF_UNKNOWN will result in returning a size of 0 bytes. |
---|
279 | */ |
---|
280 | static size_t getNumElemBytes( PixelFormat format ); |
---|
281 | |
---|
282 | /** Returns the size in bits of an element of the given pixel format. |
---|
283 | @returns |
---|
284 | The size in bits of an element. See Remarks. |
---|
285 | @remarks |
---|
286 | Passing PF_UNKNOWN will result in returning a size of 0 bits. |
---|
287 | */ |
---|
288 | static size_t getNumElemBits( PixelFormat format ); |
---|
289 | |
---|
290 | /** Returns the size in memory of a region with the given extents and pixel |
---|
291 | format with consecutive memory layout. |
---|
292 | @param width |
---|
293 | The width of the area |
---|
294 | @param height |
---|
295 | The height of the area |
---|
296 | @param depth |
---|
297 | The depth of the area |
---|
298 | @param format |
---|
299 | The format of the area |
---|
300 | @returns |
---|
301 | The size in bytes |
---|
302 | @remarks |
---|
303 | In case that the format is non-compressed, this simply returns |
---|
304 | width*height*depth*PixelUtil::getNumElemBytes(format). In the compressed |
---|
305 | case, this does serious magic. |
---|
306 | */ |
---|
307 | static size_t getMemorySize(size_t width, size_t height, size_t depth, PixelFormat format); |
---|
308 | |
---|
309 | /** Returns the property flags for this pixel format |
---|
310 | @returns |
---|
311 | A bitfield combination of PFF_HASALPHA, PFF_ISCOMPRESSED, |
---|
312 | PFF_FLOAT, PFF_DEPTH, PFF_NATIVEENDIAN, PFF_LUMINANCE |
---|
313 | @remarks |
---|
314 | This replaces the seperate functions for formatHasAlpha, formatIsFloat, ... |
---|
315 | */ |
---|
316 | static unsigned int getFlags( PixelFormat format ); |
---|
317 | |
---|
318 | /** Shortcut method to determine if the format has an alpha component */ |
---|
319 | static bool hasAlpha(PixelFormat format); |
---|
320 | /** Shortcut method to determine if the format is floating point */ |
---|
321 | static bool isFloatingPoint(PixelFormat format); |
---|
322 | /** Shortcut method to determine if the format is compressed */ |
---|
323 | static bool isCompressed(PixelFormat format); |
---|
324 | /** Shortcut method to determine if the format is a depth format. */ |
---|
325 | static bool isDepth(PixelFormat format); |
---|
326 | /** Shortcut method to determine if the format is in native endian format. */ |
---|
327 | static bool isNativeEndian(PixelFormat format); |
---|
328 | /** Shortcut method to determine if the format is a luminance format. */ |
---|
329 | static bool isLuminance(PixelFormat format); |
---|
330 | |
---|
331 | /** Return wether a certain image extent is valid for this image format. |
---|
332 | @param width |
---|
333 | The width of the area |
---|
334 | @param height |
---|
335 | The height of the area |
---|
336 | @param depth |
---|
337 | The depth of the area |
---|
338 | @param format |
---|
339 | The format of the area |
---|
340 | @remarks For non-compressed formats, this is always true. For DXT formats, |
---|
341 | only sizes with a width and height multiple of 4 and depth 1 are allowed. |
---|
342 | */ |
---|
343 | static bool isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format); |
---|
344 | |
---|
345 | /** Gives the number of bits (RGBA) for a format. See remarks. |
---|
346 | @remarks For non-colour formats (dxt, depth) this returns [0,0,0,0]. |
---|
347 | */ |
---|
348 | static void getBitDepths(PixelFormat format, int rgba[4]); |
---|
349 | |
---|
350 | /** Gives the masks for the R, G, B and A component |
---|
351 | @note Only valid for native endian formats |
---|
352 | */ |
---|
353 | static void getBitMasks(PixelFormat format, uint32 rgba[4]); |
---|
354 | |
---|
355 | /** Gets the name of an image format |
---|
356 | */ |
---|
357 | static String getFormatName(PixelFormat srcformat); |
---|
358 | |
---|
359 | /** Returns wether the format can be packed or unpacked with the packColour() |
---|
360 | and unpackColour() functions. This is generally not true for compressed and |
---|
361 | depth formats as they are special. It can only be true for formats with a |
---|
362 | fixed element size. |
---|
363 | @returns |
---|
364 | true if yes, otherwise false |
---|
365 | */ |
---|
366 | static bool isAccessible(PixelFormat srcformat); |
---|
367 | |
---|
368 | /** Returns the component type for a certain pixel format. Returns PCT_BYTE |
---|
369 | in case there is no clear component type like with compressed formats. |
---|
370 | This is one of PCT_BYTE, PCT_SHORT, PCT_FLOAT16, PCT_FLOAT32. |
---|
371 | */ |
---|
372 | static PixelComponentType getComponentType(PixelFormat fmt); |
---|
373 | |
---|
374 | /** Returns the component count for a certain pixel format. Returns 3(no alpha) or |
---|
375 | 4 (has alpha) in case there is no clear component type like with compressed formats. |
---|
376 | */ |
---|
377 | static size_t getComponentCount(PixelFormat fmt); |
---|
378 | |
---|
379 | /** Gets the format from given name. |
---|
380 | @param name The string of format name |
---|
381 | @param accessibleOnly If true, non-accessible format will treat as invalid format, |
---|
382 | otherwise, all supported format are valid. |
---|
383 | @param caseSensitive Should be set true if string match should use case sensitivity. |
---|
384 | @returns The format match the format name, or PF_UNKNOWN if is invalid name. |
---|
385 | */ |
---|
386 | static PixelFormat getFormatFromName(const String& name, bool accessibleOnly = false, bool caseSensitive = false); |
---|
387 | |
---|
388 | /** Gets the BNF expression of the pixel-formats. |
---|
389 | @note The string returned by this function is intented to use as a BNF expression |
---|
390 | to work with Compiler2Pass. |
---|
391 | @param accessibleOnly If true, only accessible pixel format will take into account, otherwise all |
---|
392 | pixel formats list in PixelFormat enumeration will being returned. |
---|
393 | @returns A string contains the BNF expression. |
---|
394 | */ |
---|
395 | static String getBNFExpressionOfPixelFormats(bool accessibleOnly = false); |
---|
396 | |
---|
397 | /** Returns the similar format but acoording with given bit depths. |
---|
398 | @param fmt The original foamt. |
---|
399 | @param integerBits Preferred bit depth (pixel bits) for integer pixel format. |
---|
400 | Available values: 0, 16 and 32, where 0 (the default) means as it is. |
---|
401 | @param floatBits Preferred bit depth (channel bits) for float pixel format. |
---|
402 | Available values: 0, 16 and 32, where 0 (the default) means as it is. |
---|
403 | @returns The format that similar original format with bit depth according |
---|
404 | with preferred bit depth, or original format if no convertion occuring. |
---|
405 | */ |
---|
406 | static PixelFormat getFormatForBitDepths(PixelFormat fmt, ushort integerBits, ushort floatBits); |
---|
407 | |
---|
408 | /** Pack a colour value to memory |
---|
409 | @param colour The colour |
---|
410 | @param pf Pixelformat in which to write the colour |
---|
411 | @param dest Destination memory location |
---|
412 | */ |
---|
413 | static void packColour(const ColourValue &colour, const PixelFormat pf, void* dest); |
---|
414 | /** Pack a colour value to memory |
---|
415 | @param r,g,b,a The four colour components, range 0x00 to 0xFF |
---|
416 | @param pf Pixelformat in which to write the colour |
---|
417 | @param dest Destination memory location |
---|
418 | */ |
---|
419 | static void packColour(const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, void* dest); |
---|
420 | /** Pack a colour value to memory |
---|
421 | @param r,g,b,a The four colour components, range 0.0f to 1.0f |
---|
422 | (an exception to this case exists for floating point pixel |
---|
423 | formats, which don't clamp to 0.0f..1.0f) |
---|
424 | @param pf Pixelformat in which to write the colour |
---|
425 | @param dest Destination memory location |
---|
426 | */ |
---|
427 | static void packColour(const float r, const float g, const float b, const float a, const PixelFormat pf, void* dest); |
---|
428 | |
---|
429 | /** Unpack a colour value from memory |
---|
430 | @param colour The colour is returned here |
---|
431 | @param pf Pixelformat in which to read the colour |
---|
432 | @param src Source memory location |
---|
433 | */ |
---|
434 | static void unpackColour(ColourValue *colour, PixelFormat pf, const void* src); |
---|
435 | /** Unpack a colour value from memory |
---|
436 | @param r,g,b,a The colour is returned here (as byte) |
---|
437 | @param pf Pixelformat in which to read the colour |
---|
438 | @param src Source memory location |
---|
439 | @remarks This function returns the colour components in 8 bit precision, |
---|
440 | this will lose precision when coming from PF_A2R10G10B10 or floating |
---|
441 | point formats. |
---|
442 | */ |
---|
443 | static void unpackColour(uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void* src); |
---|
444 | /** Unpack a colour value from memory |
---|
445 | @param r,g,b,a The colour is returned here (as float) |
---|
446 | @param pf Pixelformat in which to read the colour |
---|
447 | @param src Source memory location |
---|
448 | */ |
---|
449 | static void unpackColour(float *r, float *g, float *b, float *a, PixelFormat pf, const void* src); |
---|
450 | |
---|
451 | /** Convert consecutive pixels from one format to another. No dithering or filtering is being done. |
---|
452 | Converting from RGB to luminance takes the R channel. In case the source and destination format match, |
---|
453 | just a copy is done. |
---|
454 | @param src Pointer to source region |
---|
455 | @param srcFormat Pixel format of source region |
---|
456 | @param dst Pointer to destination region |
---|
457 | @param dstFormat Pixel format of destination region |
---|
458 | */ |
---|
459 | static void bulkPixelConversion(void *src, PixelFormat srcFormat, void *dest, PixelFormat dstFormat, unsigned int count); |
---|
460 | |
---|
461 | /** Convert pixels from one format to another. No dithering or filtering is being done. Converting |
---|
462 | from RGB to luminance takes the R channel. |
---|
463 | @param src PixelBox containing the source pixels, pitches and format |
---|
464 | @param dst PixelBox containing the destination pixels, pitches and format |
---|
465 | @remarks The source and destination boxes must have the same |
---|
466 | dimensions. In case the source and destination format match, a plain copy is done. |
---|
467 | */ |
---|
468 | static void bulkPixelConversion(const PixelBox &src, const PixelBox &dst); |
---|
469 | }; |
---|
470 | |
---|
471 | } |
---|
472 | |
---|
473 | #endif |
---|