Merge "C# binding for PixelBuffer::GetMetadata()"
[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
18 namespace Tizen.NUI
19 {
20
21     /// <summary>
22     /// Loading an image.
23     /// </summary>
24     /// <since_tizen> 5 </since_tizen>
25     public class ImageLoading
26     {
27         /// <summary>
28         /// Load an image synchronously from local file.
29         /// </summary>
30         /// <param name="url">The URL of the image file to load.</param>
31         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
32         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
33         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
34         /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
35         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
36         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
37         {
38             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
39             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_0(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
40             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41             return ret;
42         }
43
44         /// <summary>
45         /// Load an image synchronously from local file.
46         /// </summary>
47         /// <param name="url">The URL of the image file to load.</param>
48         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
49         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
50         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
51         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
52         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
53         {
54             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
55             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_1(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
56             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57             return ret;
58         }
59
60         /// <summary>
61         /// Load an image synchronously from local file.
62         /// </summary>
63         /// <param name="url">The URL of the image file to load.</param>
64         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
65         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
66         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
67         public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode)
68         {
69             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
70             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_2(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72             return ret;
73         }
74
75         /// <summary>
76         /// Load an image synchronously from local file.
77         /// </summary>
78         /// <param name="url">The URL of the image file to load.</param>
79         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
80         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
81         public static PixelBuffer LoadImageFromFile(string url, Size2D size)
82         {
83             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
84             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_3(url, Uint16Pair.getCPtr(uSize)), true);
85             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         /// <summary>
90         /// Load an image synchronously from local file.
91         /// </summary>
92         /// <param name="url">The URL of the image file to load.</param>
93         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
94         public static PixelBuffer LoadImageFromFile(string url)
95         {
96             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.LoadImageFromFile__SWIG_4(url), true);
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98             return ret;
99         }
100
101         /// <summary>
102         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
103         /// </summary>
104         /// <param name="filename">The name of the image.</param>
105         /// <param name="size">The requested size for the image</param>
106         /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
107         /// <param name="samplingMode">The image filter to use if the image needs to be downsampled to the requested size.</param>
108         /// <param name="orientationCorrection">Whether to use image metadata to rotate or flip the image, e.g., from portrait to landscape.</param>
109         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
110         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
111         {
112             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
113             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_0(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
114             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
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         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
127         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
128         {
129             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
130             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_1(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
131             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133             return ret;
134         }
135
136         /// <summary>
137         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
138         /// </summary>
139         /// <param name="filename">The name of the image.</param>
140         /// <param name="size">The requested size for the image</param>
141         /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
142         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
143         public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode)
144         {
145             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
146             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_2(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
147             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
148             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149             return ret;
150         }
151
152         /// <summary>
153         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
154         /// </summary>
155         /// <param name="filename">The name of the image.</param>
156         /// <param name="size">The requested size for the image</param>
157         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
158         public static Size2D GetClosestImageSize(string filename, Size2D size)
159         {
160             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
161             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_3(filename, Uint16Pair.getCPtr(uSize)), true);
162             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
163             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164             return ret;
165         }
166
167         /// <summary>
168         /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
169         /// </summary>
170         /// <param name="filename">The name of the image.</param>
171         /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
172         public static Size2D GetClosestImageSize(string filename)
173         {
174             var val = new Uint16Pair(NDalicPINVOKE.GetClosestImageSize__SWIG_4(filename), true);
175             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177             return ret;
178         }
179
180         /// <summary>
181         /// Load an image synchronously from a remote resource.
182         /// </summary>
183         /// <param name="url">The URL of the image file to load.</param>
184         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
185         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
186         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
187         /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
188         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
189         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
190         {
191             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
192             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_0(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194             return ret;
195         }
196
197         /// <summary>
198         /// Load an image synchronously from a remote resource.
199         /// </summary>
200         /// <param name="url">The URL of the image file to load.</param>
201         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
202         /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
203         /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
204         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
205         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
206         {
207             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
208             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_1(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
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         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
220         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode)
221         {
222             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
223             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_2(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             return ret;
226         }
227
228         /// <summary>
229         /// Load an image synchronously from a remote resource.
230         /// </summary>
231         /// <param name="url">The URL of the image file to load.</param>
232         /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
233         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
234         public static PixelBuffer DownloadImageSynchronously(string url, Size2D size)
235         {
236             var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
237             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_3(url, Uint16Pair.getCPtr(uSize)), true);
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239             return ret;
240         }
241
242         /// <summary>
243         /// Load an image synchronously from a remote resource.
244         /// </summary>
245         /// <param name="url">The URL of the image file to load.</param>
246         /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
247         public static PixelBuffer DownloadImageSynchronously(string url)
248         {
249             PixelBuffer ret = new PixelBuffer(NDalicPINVOKE.DownloadImageSynchronously__SWIG_4(url), true);
250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             return ret;
252         }
253
254         /// <summary>
255         /// Set the maximum texture size. Then size can be kwown by GL_MAX_TEXTURE_SIZE.
256         /// </summary>
257         /// <param name="size">The maximum texture size to set.</param>
258         public static void SetMaxTextureSize(uint size)
259         {
260             NDalicPINVOKE.SetMaxTextureSize(size);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262         }
263
264         /// <summary>
265         /// Get the maximum texture size.
266         /// </summary>
267         /// <returns>The maximum texture size.</returns>
268         public static uint GetMaxTextureSize()
269         {
270             uint ret = NDalicPINVOKE.GetMaxTextureSize();
271             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272             return ret;
273         }
274
275     }
276
277 }