English Review: NUI public files (#434)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / ImageLoading.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21
22     /// <summary>
23     /// Loading an image.
24     /// </summary>
25     /// <since_tizen> 5 </since_tizen>
26     /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class ImageLoading
29     {
30         /// <summary>
31         /// Load an image synchronously from local file.
32         /// </summary>
33         /// <param name="url">The URL of the image file to load.</param>
34         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
35         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
36         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
37         /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
38         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
39         /// <since_tizen> 5 </since_tizen>
40         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
43         {
44             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
45             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_0(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
46             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
47             return ret;
48         }
49
50         /// <summary>
51         /// Load an image synchronously from local file.
52         /// </summary>
53         /// <param name="url">The URL of the image file to load.</param>
54         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
55         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
56         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
57         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
58         /// <since_tizen> 5 </since_tizen>
59         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
60         [EditorBrowsable(EditorBrowsableState.Never)]
61         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
62         {
63             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
64             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_1(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
65             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66             return ret;
67         }
68
69         /// <summary>
70         /// Load an image synchronously from local file.
71         /// </summary>
72         /// <param name="url">The URL of the image file to load.</param>
73         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
74         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
75         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
76         /// <since_tizen> 5 </since_tizen>
77         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode)
80         {
81             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
82             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_2(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
83             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84             return ret;
85         }
86
87         /// <summary>
88         /// Load an image synchronously from local file.
89         /// </summary>
90         /// <param name="url">The URL of the image file to load.</param>
91         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
92         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
93         /// <since_tizen> 5 </since_tizen>
94         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
95         [EditorBrowsable(EditorBrowsableState.Never)]
96         public static PixelBuffer LoadImageFromFile(string url, Size2D size)
97         {
98             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
99             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_3(url, Uint16Pair.getCPtr(uSize)), true);
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101             return ret;
102         }
103
104         /// <summary>
105         /// Load an image synchronously from local file.
106         /// </summary>
107         /// <param name="url">The URL of the image file to load.</param>
108         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
109         /// <since_tizen> 5 </since_tizen>
110         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
111         [EditorBrowsable(EditorBrowsableState.Never)]
112         public static PixelBuffer LoadImageFromFile(string url)
113         {
114             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_4(url), true);
115             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116             return ret;
117         }
118
119         /// <summary>
120         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
121         /// </summary>
122         /// <param name="filename">The name of the image.</param>
123         /// <param name="size">The requested size for the image.</param>
124         /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
125         /// <param name="samplingMode">The image filter to use if the image needs to be downsampled to the requested size.</param>
126         /// <param name="orientationCorrection">Whether to use image metadata to rotate or flip the image, for example, from portrait to landscape.</param>
127         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
128         /// <since_tizen> 5 </since_tizen>
129         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
130         [EditorBrowsable(EditorBrowsableState.Never)]
131         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
132         {
133             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
134             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_0(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
135             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137             return ret;
138         }
139
140         /// <summary>
141         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
142         /// </summary>
143         /// <param name="filename">The name of the image.</param>
144         /// <param name="size">The requested size for the image</param>
145         /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
146         /// <param name="samplingMode">The image filter to use if the image needs to be downsampled to the requested size.</param>
147         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
148         /// <since_tizen> 5 </since_tizen>
149         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
150         [EditorBrowsable(EditorBrowsableState.Never)]
151         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
152         {
153             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
154             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_1(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
155             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
156             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157             return ret;
158         }
159
160         /// <summary>
161         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
162         /// </summary>
163         /// <param name="filename">The name of the image.</param>
164         /// <param name="size">The requested size for the image</param>
165         /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
166         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
167         /// <since_tizen> 5 </since_tizen>
168         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
169         [EditorBrowsable(EditorBrowsableState.Never)]
170         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode)
171         {
172             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
173             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_2(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
174             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176             return ret;
177         }
178
179         /// <summary>
180         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
181         /// </summary>
182         /// <param name="filename">The name of the image.</param>
183         /// <param name="size">The requested size for the image</param>
184         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
185         /// <since_tizen> 5 </since_tizen>
186         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
187         [EditorBrowsable(EditorBrowsableState.Never)]
188         public static Size2D GetClosestImageSize(string filename, Size2D size)
189         {
190             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
191             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_3(filename, Uint16Pair.getCPtr(uSize)), true);
192             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194             return ret;
195         }
196
197         /// <summary>
198         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
199         /// </summary>
200         /// <param name="filename">The name of the image.</param>
201         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
202         /// <since_tizen> 5 </since_tizen>
203         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
204         [EditorBrowsable(EditorBrowsableState.Never)]
205         public static Size2D GetClosestImageSize(string filename)
206         {
207             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_4(filename), true);
208             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
209             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210             return ret;
211         }
212
213         /// <summary>
214         /// Load an image synchronously from a remote resource.
215         /// </summary>
216         /// <param name="url">The URL of the image file to load.</param>
217         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
218         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
219         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
220         /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
221         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
222         /// <since_tizen> 5 </since_tizen>
223         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
224         [EditorBrowsable(EditorBrowsableState.Never)]
225         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
226         {
227             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
228             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_0(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230             return ret;
231         }
232
233         /// <summary>
234         /// Load an image synchronously from a remote resource.
235         /// </summary>
236         /// <param name="url">The URL of the image file to load.</param>
237         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
238         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
239         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
240         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
241         /// <since_tizen> 5 </since_tizen>
242         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
243         [EditorBrowsable(EditorBrowsableState.Never)]
244         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
245         {
246             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
247             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_1(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
248             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249             return ret;
250         }
251
252         /// <summary>
253         /// Load an image synchronously from a remote resource.
254         /// </summary>
255         /// <param name="url">The URL of the image file to load.</param>
256         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
257         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
258         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
259         /// <since_tizen> 5 </since_tizen>
260         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
261         [EditorBrowsable(EditorBrowsableState.Never)]
262         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode)
263         {
264             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
265             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_2(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267             return ret;
268         }
269
270         /// <summary>
271         /// Load an image synchronously from a remote resource.
272         /// </summary>
273         /// <param name="url">The URL of the image file to load.</param>
274         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
275         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
276         /// <since_tizen> 5 </since_tizen>
277         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
278         [EditorBrowsable(EditorBrowsableState.Never)]
279         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size)
280         {
281             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
282             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_3(url, Uint16Pair.getCPtr(uSize)), true);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284             return ret;
285         }
286
287         /// <summary>
288         /// Load an image synchronously from a remote resource.
289         /// </summary>
290         /// <param name="url">The URL of the image file to load.</param>
291         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
292         /// <since_tizen> 5 </since_tizen>
293         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
294         [EditorBrowsable(EditorBrowsableState.Never)]
295         public static PixelBuffer DownloadImageSynchronously(string url)
296         {
297             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_4(url), true);
298             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299             return ret;
300         }
301
302         /// <summary>
303         /// Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
304         /// </summary>
305         /// <param name="size">The maximum texture size to set.</param>
306         /// <since_tizen> 5 </since_tizen>
307         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
308         [EditorBrowsable(EditorBrowsableState.Never)]
309         public static void SetMaxTextureSize(uint size)
310         {
311             NDalicPINVOKE.SetMaxTextureSize(size);
312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313         }
314
315         /// <summary>
316         /// Get the maximum texture size.
317         /// </summary>
318         /// <returns>The maximum texture size.</returns>
319         /// <since_tizen> 5 </since_tizen>
320         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
321         [EditorBrowsable(EditorBrowsableState.Never)]
322         public static uint GetMaxTextureSize()
323         {
324             uint ret = NDalicPINVOKE.GetMaxTextureSize();
325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326             return ret;
327         }
328     }
329 }