2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/public-api/images/pixel.h>
19 #include <dali/public-api/images/pixel-extras.h>
22 #include <dali/integration-api/debug.h>
27 bool Pixel::HasAlpha(Format pixelformat)
39 // Note, Can be used for alpha if you want: COMPRESSED_R11_EAC, ///< ETC2 / EAC single-channel, unsigned
40 // Note, Can be used for alpha if you want: COMPRESSED_SIGNED_R11_EAC, ///< ETC2 / EAC single-channel, signed
41 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
42 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
43 case COMPRESSED_RGBA8_ETC2_EAC:
44 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
52 case RGB8888: // alpha not used
53 case BGR8888: // alpha not used
55 case COMPRESSED_R11_EAC:
56 case COMPRESSED_SIGNED_R11_EAC:
57 case COMPRESSED_RG11_EAC:
58 case COMPRESSED_SIGNED_RG11_EAC:
59 case COMPRESSED_RGB8_ETC2:
60 case COMPRESSED_SRGB8_ETC2:
61 case COMPRESSED_RGB8_ETC1:
62 case COMPRESSED_RGB_PVRTC_4BPPV1:
70 unsigned int Pixel::GetBytesPerPixel(Format pixelFormat)
104 case COMPRESSED_R11_EAC:
105 case COMPRESSED_SIGNED_R11_EAC:
106 case COMPRESSED_RG11_EAC:
107 case COMPRESSED_SIGNED_RG11_EAC:
108 case COMPRESSED_RGB8_ETC2:
109 case COMPRESSED_SRGB8_ETC2:
110 case COMPRESSED_RGB8_ETC1:
111 case COMPRESSED_RGB_PVRTC_4BPPV1:
112 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
113 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
114 case COMPRESSED_RGBA8_ETC2_EAC:
115 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
117 DALI_LOG_ERROR("Pixel formats for compressed images do not have meaningful integer bits per pixel values.\n");
124 bool Pixel::IsEncoded( const Format pixelFormat )
128 // All "normal" formats of addressable packed pixels are not encoded:
147 // All compressed texture formats are encoded:
148 case COMPRESSED_R11_EAC:
149 case COMPRESSED_SIGNED_R11_EAC:
150 case COMPRESSED_RG11_EAC:
151 case COMPRESSED_SIGNED_RG11_EAC:
152 case COMPRESSED_RGB8_ETC2:
153 case COMPRESSED_SRGB8_ETC2:
154 case COMPRESSED_RGB8_ETC1:
155 case COMPRESSED_RGB_PVRTC_4BPPV1:
156 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
157 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
158 case COMPRESSED_RGBA8_ETC2_EAC:
159 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
161 // Fall through to default return value:
168 void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitMask)
222 case COMPRESSED_R11_EAC:
223 case COMPRESSED_SIGNED_R11_EAC:
224 case COMPRESSED_RG11_EAC:
225 case COMPRESSED_SIGNED_RG11_EAC:
226 case COMPRESSED_RGB8_ETC2:
227 case COMPRESSED_SRGB8_ETC2:
228 case COMPRESSED_RGB8_ETC1:
229 case COMPRESSED_RGB_PVRTC_4BPPV1:
230 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
231 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
232 case COMPRESSED_RGBA8_ETC2_EAC:
233 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
235 DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n");