Updated header files to new format too
[platform/core/uifw/dali-adaptor.git] / dali / internal / imaging / common / pixel-manipulation.h
1 #ifndef DALI_INTERNAL_ADAPTOR_PIXEL_MANIPULATION_H
2 #define DALI_INTERNAL_ADAPTOR_PIXEL_MANIPULATION_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 #include <dali/public-api/images/pixel.h>
21
22 namespace Dali
23 {
24 namespace Internal
25 {
26 namespace Adaptor
27 {
28 enum Channel
29 {
30   LUMINANCE,
31   RED,
32   GREEN,
33   BLUE,
34   ALPHA,
35   DEPTH,
36   STENCIL,
37   MAX_NUMBER_OF_CHANNELS
38 };
39
40 /**
41  * Return true if the channel exists in the pixel format
42  * @param[in] pixelFormat The pixelFormat
43  * @param[in] channel The channel to test for
44  * @return true if the channel exists
45  */
46 bool HasChannel(Dali::Pixel::Format pixelFormat, Channel channel);
47
48 /**
49  * Read a colour channel from the pixel with the given pixel format.
50  * Returns zero if the format does not support the channel
51  * @param[in] pixelData Location of the pixel
52  * @param[in] pixelFormat The format of the pixel
53  * @param[in] channel The channel to read
54  * @return the channel value
55  */
56 unsigned int ReadChannel(unsigned char*      pixelData,
57                          Dali::Pixel::Format pixelFormat,
58                          Channel             channel);
59
60 /**
61  * Write a colour channel to the pixel with the given pixel format.
62  * @param[in] pixelData Location of the pixel
63  * @param[in] pixelFormat The format of the pixel
64  * @param[in] channel The channel to write
65  * @param[in] channelValue the value to write to the channel
66  */
67 void WriteChannel(unsigned char*      pixelData,
68                   Dali::Pixel::Format pixelFormat,
69                   Channel             channel,
70                   unsigned int        channelValue);
71
72 /**
73  * Convert the colors in the source pixel from their natural format to RGBA8888.
74  * @param[in] srcBuffer The source buffer to read from
75  * @param[in] srcOffset The offset of the pixel to convert
76  * @param[in] srcFormat The pixel format of the source pixel
77  * @param[in] destBuffer The destination buffer to write to
78  * @param[in] destOffset The offset of the pixel to write
79  */
80 void ConvertColorChannelsToRGBA8888(
81   unsigned char* srcBuffer, int srcOffset, Dali::Pixel::Format srcFormat, unsigned char* destBuffer, int destOffset);
82
83 /**
84  * Convert the alpha in the source pixel to A8.
85  * @param[in] srcBuffer The source buffer to read from
86  * @param[in] srcOffset The offset of the pixel to convert
87  * @param[in] srcFormat The pixel format of the source pixel
88  * @return the alpha value in the range 0-255
89  */
90 int ConvertAlphaChannelToA8(unsigned char* srcPixel, int srcOffset, Dali::Pixel::Format srcFormat);
91
92 } // namespace Adaptor
93 } // namespace Internal
94 } // namespace Dali
95
96 #endif // DALI_INTERNAL_ADAPTOR_PIXEL_MANIPULATION_H