[NUI] remove input method dependency from View.ControlState (#1585)
[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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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(Interop.ImageLoading.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         /// Get the size of an original image
215         /// </summary>
216         /// <param name="filename">The name of the image.</param>
217         /// <returns>Dimension of the original image.</returns>
218         /// <since_tizen> 5 </since_tizen>
219         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
220         [EditorBrowsable(EditorBrowsableState.Never)]
221         public static Size2D GetOriginalImageSize(string filename)
222         {
223             var val = new Uint16Pair(Interop.ImageLoading.GetOriginalImageSize(filename), true);
224             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226             return ret;
227         }
228
229         /// <summary>
230         /// Load an image synchronously from a remote resource.
231         /// </summary>
232         /// <param name="url">The URL of the image file to load.</param>
233         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
234         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
235         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
236         /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
237         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
238         /// <since_tizen> 5 </since_tizen>
239         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
240         [EditorBrowsable(EditorBrowsableState.Never)]
241         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
242         {
243             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
244             PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously__SWIG_0(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246             return ret;
247         }
248
249         /// <summary>
250         /// Load an image synchronously from a remote resource.
251         /// </summary>
252         /// <param name="url">The URL of the image file to load.</param>
253         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
254         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
255         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
256         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
257         /// <since_tizen> 5 </since_tizen>
258         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
259         [EditorBrowsable(EditorBrowsableState.Never)]
260         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
261         {
262             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
263             PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously__SWIG_1(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
264             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265             return ret;
266         }
267
268         /// <summary>
269         /// Load an image synchronously from a remote resource.
270         /// </summary>
271         /// <param name="url">The URL of the image file to load.</param>
272         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
273         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
274         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
275         /// <since_tizen> 5 </since_tizen>
276         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
277         [EditorBrowsable(EditorBrowsableState.Never)]
278         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode)
279         {
280             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
281             PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously__SWIG_2(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283             return ret;
284         }
285
286         /// <summary>
287         /// Load an image synchronously from a remote resource.
288         /// </summary>
289         /// <param name="url">The URL of the image file to load.</param>
290         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</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, Size2D size)
296         {
297             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
298             PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously__SWIG_3(url, Uint16Pair.getCPtr(uSize)), true);
299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             return ret;
301         }
302
303         /// <summary>
304         /// Load an image synchronously from a remote resource.
305         /// </summary>
306         /// <param name="url">The URL of the image file to load.</param>
307         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
308         /// <since_tizen> 5 </since_tizen>
309         /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
310         [EditorBrowsable(EditorBrowsableState.Never)]
311         public static PixelBuffer DownloadImageSynchronously(string url)
312         {
313             PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously__SWIG_4(url), true);
314             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315             return ret;
316         }
317
318     }
319 }