[ImageUtil] Remove deprecated API and change native pinvoke APIs (#5950)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Util / ImageUtil / ImageUtilEnums.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Diagnostics;
19
20 namespace Tizen.Multimedia.Util
21 {
22     /// <summary>
23     /// Specifies the JPEG Downscale options for decoding.
24     /// </summary>
25     /// <since_tizen> 4 </since_tizen>
26     public enum JpegDownscale
27     {
28         /// <summary>
29         /// No downscale.
30         /// </summary>
31         None,
32         /// <summary>
33         /// 1/2 downscale.
34         /// </summary>
35         OneHalf,
36         /// <summary>
37         /// 1/4 downscale.
38         /// </summary>
39         OneFourth,
40         /// <summary>
41         /// 1/8 downscale.
42         /// </summary>
43         OneEighth,
44     }
45
46     /// <summary>
47     /// Specifies the PNG compression levels.
48     /// </summary>
49     /// <since_tizen> 4 </since_tizen>
50     public enum PngCompression
51     {
52         /// <summary>
53         /// No Compression.
54         /// </summary>
55         None,
56         /// <summary>
57         /// Compression Level 1. Best speed.
58         /// </summary>
59         Level1,
60         /// <summary>
61         /// Compression Level 2.
62         /// </summary>
63         Level2,
64         /// <summary>
65         /// Compression Level 3.
66         /// </summary>
67         Level3,
68         /// <summary>
69         /// Compression Level 4.
70         /// </summary>
71         Level4,
72         /// <summary>
73         /// Compression Level 5.
74         /// </summary>
75         Level5,
76         /// <summary>
77         /// Compression Level 6.
78         /// </summary>
79         Level6,
80         /// <summary>
81         /// Compression Level 7.
82         /// </summary>
83         Level7,
84         /// <summary>
85         /// Compression Level 8.
86         /// </summary>
87         Level8,
88         /// <summary>
89         /// Compression Level 9.
90         /// </summary>
91         Level9,
92     }
93
94     internal enum AnimationType
95     {
96         /// <summary>
97         /// GIF
98         /// </summary>
99         Gif,
100         /// <summary>
101         /// WebP
102         /// </summary>
103         WebP
104     }
105
106     /// <summary>
107     /// Specifies how an image is rotated or flipped.
108     /// </summary>
109     /// <seealso cref="RotateTransform"/>
110     internal enum ImageRotation
111     {
112         /// <summary>
113         /// No rotation.
114         /// </summary>
115         Rotate0,
116         /// <summary>
117         /// Rotate 90 degree clockwise.
118         /// </summary>
119         Rotate90,
120         /// <summary>
121         /// Rotate 180 degree clockwise.
122         /// </summary>
123         Rotate180,
124         /// <summary>
125         /// Rotate 270 degree clockwise.
126         /// </summary>
127         Rotate270,
128         /// <summary>
129         /// Flip horizontally.
130         /// </summary>
131         FlipHorizontal,
132         /// <summary>
133         /// Flip vertically.
134         /// </summary>
135         FlipVertical,
136     }
137
138     internal enum ImageColorSpace
139     {
140         /// <summary>
141         /// YV12 - YCrCb planar format.
142         /// </summary>
143         YV12,
144         /// <summary>
145         /// YUV422 - planar.
146         /// </summary>
147         Yuv422,
148         /// <summary>
149         /// YUV420 - planar.
150         /// </summary>
151         I420,
152         /// <summary>
153         /// NV12- planar.
154         /// </summary>
155         NV12,
156         /// <summary>
157         /// UYVY - packed.
158         /// </summary>
159         Uyvy,
160         /// <summary>
161         /// YUYV - packed.
162         /// </summary>
163         Yuyv,
164         /// <summary>
165         /// RGB565, high-byte is blue.
166         /// </summary>
167         Rgb565,
168         /// <summary>
169         /// RGB888, high-byte is blue.
170         /// </summary>
171         Rgb888,
172         /// <summary>
173         /// ARGB8888, high-byte is blue.
174         /// </summary>
175         Argb8888,
176         /// <summary>
177         /// BGRA8888, high-byte is alpha.
178         /// </summary>
179         Bgra8888,
180         /// <summary>
181         /// RGBA8888, high-byte is alpha.
182         /// </summary>
183         Rgba8888,
184         /// <summary>
185         /// BGRX8888, high-byte is X.
186         /// </summary>
187         Bgrx8888,
188         /// <summary>
189         /// NV21- planar.
190         /// </summary>
191         NV21,
192         /// <summary>
193         /// NV16- planar.
194         /// </summary>
195         NV16,
196         /// <summary>
197         /// NV61- planar.
198         /// </summary>
199         NV61,
200     }
201
202     internal static class ImageColorSpaceExtensions
203     {
204         internal static ColorSpace ToCommonColorSpace(this ImageColorSpace value)
205         {
206             Debug.Assert(Enum.IsDefined(typeof(ImageColorSpace), value));
207
208             switch (value)
209             {
210                 case ImageColorSpace.YV12: return ColorSpace.YV12;
211                 case ImageColorSpace.Uyvy: return ColorSpace.Uyvy;
212                 case ImageColorSpace.Yuyv: return ColorSpace.Yuyv;
213                 case ImageColorSpace.Yuv422: return ColorSpace.Yuv422P;
214                 case ImageColorSpace.I420: return ColorSpace.I420;
215                 case ImageColorSpace.Rgb565: return ColorSpace.Rgb565;
216                 case ImageColorSpace.Rgb888: return ColorSpace.Rgb888;
217                 case ImageColorSpace.Argb8888: return ColorSpace.Argb8888;
218                 case ImageColorSpace.Bgra8888: return ColorSpace.Bgra8888;
219                 case ImageColorSpace.Rgba8888: return ColorSpace.Rgba8888;
220                 case ImageColorSpace.Bgrx8888: return ColorSpace.Bgrx8888;
221                 case ImageColorSpace.NV12: return ColorSpace.NV12;
222                 case ImageColorSpace.NV16: return ColorSpace.NV16;
223                 case ImageColorSpace.NV21: return ColorSpace.NV21;
224                 case ImageColorSpace.NV61: return ColorSpace.NV61;
225                 default: break;
226             }
227
228             Debug.Fail($"Not supported color space : {value.ToString()}!");
229             throw new NotSupportedException("Implementation does not support the specified value.");
230         }
231     }
232
233     internal static class ImageColorSpaceSupport
234     {
235         internal static ImageColorSpace ToImageColorSpace(this ColorSpace colorSpace)
236         {
237             ValidationUtil.ValidateEnum(typeof(ColorSpace), colorSpace, nameof(colorSpace));
238
239             switch (colorSpace)
240             {
241                 case ColorSpace.YV12: return ImageColorSpace.YV12;
242                 case ColorSpace.Uyvy: return ImageColorSpace.Uyvy;
243                 case ColorSpace.Yuyv: return ImageColorSpace.Yuyv;
244                 case ColorSpace.Yuv422: return ImageColorSpace.Yuv422;
245                 case ColorSpace.I420: return ImageColorSpace.I420;
246                 case ColorSpace.Rgb565: return ImageColorSpace.Rgb565;
247                 case ColorSpace.Rgb888: return ImageColorSpace.Rgb888;
248                 case ColorSpace.Argb8888: return ImageColorSpace.Argb8888;
249                 case ColorSpace.Bgra8888: return ImageColorSpace.Bgra8888;
250                 case ColorSpace.Rgba8888: return ImageColorSpace.Rgba8888;
251                 case ColorSpace.Bgrx8888: return ImageColorSpace.Bgrx8888;
252                 case ColorSpace.NV12: return ImageColorSpace.NV12;
253                 case ColorSpace.NV16: return ImageColorSpace.NV16;
254                 case ColorSpace.NV21: return ImageColorSpace.NV21;
255                 case ColorSpace.NV61: return ImageColorSpace.NV61;
256                 default: break;
257             }
258
259             throw new NotSupportedException($"The ColorSpace.{colorSpace.ToString()} is not supported.");
260         }
261     }
262 }