2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/images/pixel.h>
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/integration-api/debug.h>
28 bool Pixel::HasAlpha(Format pixelformat)
40 // Note, Can be used for alpha if you want: COMPRESSED_R11_EAC, ///< ETC2 / EAC single-channel, unsigned
41 // Note, Can be used for alpha if you want: COMPRESSED_SIGNED_R11_EAC, ///< ETC2 / EAC single-channel, signed
42 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
43 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
44 case COMPRESSED_RGBA8_ETC2_EAC:
45 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
53 case RGB8888: // alpha not used
54 case BGR8888: // alpha not used
56 case COMPRESSED_R11_EAC:
57 case COMPRESSED_SIGNED_R11_EAC:
58 case COMPRESSED_RG11_EAC:
59 case COMPRESSED_SIGNED_RG11_EAC:
60 case COMPRESSED_RGB8_ETC2:
61 case COMPRESSED_SRGB8_ETC2:
62 case COMPRESSED_RGB8_ETC1:
63 case COMPRESSED_RGB_PVRTC_4BPPV1:
71 unsigned int Pixel::GetBytesPerPixel(Format pixelFormat)
105 case COMPRESSED_R11_EAC:
106 case COMPRESSED_SIGNED_R11_EAC:
107 case COMPRESSED_RG11_EAC:
108 case COMPRESSED_SIGNED_RG11_EAC:
109 case COMPRESSED_RGB8_ETC2:
110 case COMPRESSED_SRGB8_ETC2:
111 case COMPRESSED_RGB8_ETC1:
112 case COMPRESSED_RGB_PVRTC_4BPPV1:
113 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
114 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
115 case COMPRESSED_RGBA8_ETC2_EAC:
116 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
118 DALI_LOG_ERROR("Pixel formats for compressed images do not have meaningful integer bits per pixel values.\n");
125 void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitMask)
179 case COMPRESSED_R11_EAC:
180 case COMPRESSED_SIGNED_R11_EAC:
181 case COMPRESSED_RG11_EAC:
182 case COMPRESSED_SIGNED_RG11_EAC:
183 case COMPRESSED_RGB8_ETC2:
184 case COMPRESSED_SRGB8_ETC2:
185 case COMPRESSED_RGB8_ETC1:
186 case COMPRESSED_RGB_PVRTC_4BPPV1:
187 case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
188 case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
189 case COMPRESSED_RGBA8_ETC2_EAC:
190 case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
192 DALI_LOG_ERROR("Pixel formats for compressed images are not compatible with simple masking-out of per-pixel alpha.\n");