1 #ifndef __DALI_PIXEL_H__
2 #define __DALI_PIXEL_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://floralicense.org/license/
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
21 * @addtogroup CAPI_DALI_FRAMEWORK
26 #include <dali/public-api/common/dali-common.h>
28 namespace Dali DALI_IMPORT_API
32 * Pixel format types and their properties.
37 /// @note: BitmapImage::BufferUpdated might not work with BGR/BGRA formats!
38 enum Format ///< pixel format, default color depth is RGBA 32 bit with alpha
40 // Start at > 0 to distinguish null data:
41 A8 = 1, ///< color depth 8-bit, alpha
42 L8, ///< color depth 8-bit, luminance
43 LA88, ///< color depth 16-bit, luminance with 8 bit alpha
44 RGB565, ///< color depth 16 bit, 5-6-5
45 BGR565, ///< color depth 16 bit, 5-6-5
46 RGBA4444, ///< color depth 16 bit with alpha, 4-4-4-4
47 BGRA4444, ///< color depth 16 bit with alpha, 4-4-4-4
48 RGBA5551, ///< color depth 16 bit with alpha, 5-5-5-1
49 BGRA5551, ///< color depth 16 bit with alpha, 5-5-5-1
50 RGB888, ///< color depth 24 bit, 8-8-8
51 RGB8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8#
52 BGR8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8#
53 RGBA8888, ///< color depth 32 bit with alpha, 8-8-8-8
54 BGRA8888, ///< color depth 32 bit with alpha, 8-8-8-8
55 // GLES 3 Standard compressed formats:
56 COMPRESSED_R11_EAC, ///< ETC2 / EAC single-channel, unsigned
57 COMPRESSED_SIGNED_R11_EAC, ///< ETC2 / EAC single-channel, signed
58 COMPRESSED_RG11_EAC, ///< ETC2 / EAC dual-channel, unsigned
59 COMPRESSED_SIGNED_RG11_EAC, ///< ETC2 / EAC dual-channel, signed
60 COMPRESSED_RGB8_ETC2, ///< ETC2 / EAC RGB
61 COMPRESSED_SRGB8_ETC2, ///< ETC2 / EAC RGB using sRGB colourspace.
62 COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, ///< ETC2 / EAC RGB with single bit per pixel alpha mask.
63 COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,///< ETC2 / EAC RGB using sRGB colourspace, with single bit per pixel alpha mask.
64 COMPRESSED_RGBA8_ETC2_EAC, ///< ETC2 / EAC RGB plus separate alpha channel.
65 COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, ///< ETC2 / EAC RGB using sRGB colourspace, plus separate alpha channel.
66 // GLES 2 extension compressed formats:
67 COMPRESSED_RGB8_ETC1, ///< ETC1 RGB as defined by GLES 2 extension OES_compressed_ETC1_RGB8_texture: http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
68 COMPRESSED_RGB_PVRTC_4BPPV1 ///< PowerVR 4bpp RGB format (v1) as defined by extension IMG_texture_compression_pvrtc: http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt
69 ///! Update LAST_VALID_PIXEL_FORMAT below if you add an enum value here.
72 /** For asserting that a variable has a valid pixel format.
73 * Sync it to the first value above. */
74 const Format FIRST_VALID_PIXEL_FORMAT = A8;
76 /** For asserting that a variable has a valid pixel format.
77 * Sync it to the last value above. */
78 const Format LAST_VALID_PIXEL_FORMAT = COMPRESSED_RGB_PVRTC_4BPPV1;
81 * Whether specified pixel format contains an alpha value
82 * @param [in] pixelformat pixel format
83 * @return true if format has alpha, false otherwise
85 bool HasAlpha(Format pixelformat);
88 * Returns The number of bytes per pixel for the specified pixel format
89 * @param [in] pixelFormat The pixel format
90 * @return The number of bytes per pixel
92 unsigned int GetBytesPerPixel(Format pixelFormat);
95 * Returns the offset of the byte containing the alpha mask from the start of the pixel data
96 * and the bitmask of that byte to get the alpha value.
97 * Bitmask is zero if the pixelFormat does not support alpha
98 * @param[in] pixelFormat
99 * @param[out] byteOffset the byte offset
100 * @param[out] bitMask the bitmask
102 void GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitMask);
111 #endif // __DALI_PIXEL_H__