2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
26 /// <since_tizen> 5 </since_tizen>
27 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class ImageLoading
32 /// Load an image synchronously from local file.
34 /// <param name="url">The URL of the image file to load.</param>
35 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
36 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
37 /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
38 /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
39 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
40 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
41 /// <since_tizen> 5 </since_tizen>
42 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
48 throw new ArgumentNullException(nameof(size));
50 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
51 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.LoadImageFromFile(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
52 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 /// Load an image synchronously from local file.
59 /// <param name="url">The URL of the image file to load.</param>
60 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
61 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
62 /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
63 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
64 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
65 /// <since_tizen> 5 </since_tizen>
66 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
72 throw new ArgumentNullException(nameof(size));
74 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
75 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.LoadImageFromFile(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Load an image synchronously from local file.
83 /// <param name="url">The URL of the image file to load.</param>
84 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
85 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
86 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
87 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
88 /// <since_tizen> 5 </since_tizen>
89 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
90 [EditorBrowsable(EditorBrowsableState.Never)]
91 public static PixelBuffer LoadImageFromFile(string url, Size2D size, FittingModeType fittingMode)
95 throw new ArgumentNullException(nameof(size));
97 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
98 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.LoadImageFromFile(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
99 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Load an image synchronously from local file.
106 /// <param name="url">The URL of the image file to load.</param>
107 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
108 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
109 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
110 /// <since_tizen> 5 </since_tizen>
111 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
112 [EditorBrowsable(EditorBrowsableState.Never)]
113 public static PixelBuffer LoadImageFromFile(string url, Size2D size)
117 throw new ArgumentNullException(nameof(size));
119 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
120 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.LoadImageFromFile(url, Uint16Pair.getCPtr(uSize)), true);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 /// Load an image synchronously from local file.
128 /// <param name="url">The URL of the image file to load.</param>
129 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case loading failed.</returns>
130 /// <since_tizen> 5 </since_tizen>
131 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public static PixelBuffer LoadImageFromFile(string url)
135 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.LoadImageFromFile(url), true);
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
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 /// <param name="orientationCorrection">Whether to use image metadata to rotate or flip the image, for example, from portrait to landscape.</param>
148 /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
149 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
150 /// <since_tizen> 5 </since_tizen>
151 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
152 [EditorBrowsable(EditorBrowsableState.Never)]
153 public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
157 throw new ArgumentNullException(nameof(size));
159 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
160 var val = new Uint16Pair(Interop.ImageLoading.GetClosestImageSize(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
161 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
169 /// <param name="filename">The name of the image.</param>
170 /// <param name="size">The requested size for the image</param>
171 /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
172 /// <param name="samplingMode">The image filter to use if the image needs to be downsampled to the requested size.</param>
173 /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
174 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
175 /// <since_tizen> 5 </since_tizen>
176 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
177 [EditorBrowsable(EditorBrowsableState.Never)]
178 public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
182 throw new ArgumentNullException(nameof(size));
184 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
185 var val = new Uint16Pair(Interop.ImageLoading.GetClosestImageSize(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
186 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
194 /// <param name="filename">The name of the image.</param>
195 /// <param name="size">The requested size for the image</param>
196 /// <param name="fittingMode">The method to use to map the source image to the desired dimensions.</param>
197 /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
198 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
199 /// <since_tizen> 5 </since_tizen>
200 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
201 [EditorBrowsable(EditorBrowsableState.Never)]
202 public static Size2D GetClosestImageSize(string filename, Size2D size, FittingModeType fittingMode)
206 throw new ArgumentNullException(nameof(size));
208 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
209 var val = new Uint16Pair(Interop.ImageLoading.GetClosestImageSize(filename, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
210 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216 /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
218 /// <param name="filename">The name of the image.</param>
219 /// <param name="size">The requested size for the image</param>
220 /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
221 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
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 Size2D GetClosestImageSize(string filename, Size2D size)
229 throw new ArgumentNullException(nameof(size));
231 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
232 var val = new Uint16Pair(Interop.ImageLoading.GetClosestImageSize(filename, Uint16Pair.getCPtr(uSize)), true);
233 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 /// Determine the size of an image that LoadImageFromFile will provide when given the same image loading parameters.
241 /// <param name="filename">The name of the image.</param>
242 /// <returns>Dimensions that image will have if it is loaded with given parameters.</returns>
243 /// <since_tizen> 5 </since_tizen>
244 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
245 [EditorBrowsable(EditorBrowsableState.Never)]
246 public static Size2D GetClosestImageSize(string filename)
248 var val = new Uint16Pair(Interop.ImageLoading.GetClosestImageSize(filename), true);
249 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 /// Get the size of an original image
257 /// <param name="filename">The name of the image.</param>
258 /// <returns>Dimension of the original image.</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 Size2D GetOriginalImageSize(string filename)
264 var val = new Uint16Pair(Interop.ImageLoading.GetOriginalImageSize(filename), true);
265 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 /// Load an image synchronously from a remote resource.
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 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
276 /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
277 /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
278 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
279 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
280 /// <since_tizen> 5 </since_tizen>
281 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
282 [EditorBrowsable(EditorBrowsableState.Never)]
283 public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode, bool orientationCorrection)
287 throw new ArgumentNullException(nameof(size));
289 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
290 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode, orientationCorrection), true);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 /// Load an image synchronously from a remote resource.
298 /// <param name="url">The URL of the image file to load.</param>
299 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
300 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
301 /// <param name="samplingMode">The filtering method used when sampling pixels from the input image while fitting it to desired size.</param>
302 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
303 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
304 /// <since_tizen> 5 </since_tizen>
305 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
306 [EditorBrowsable(EditorBrowsableState.Never)]
307 public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode, SamplingModeType samplingMode)
311 throw new ArgumentNullException(nameof(size));
313 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
314 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously(url, Uint16Pair.getCPtr(uSize), (int)fittingMode, (int)samplingMode), true);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 /// Load an image synchronously from a remote resource.
322 /// <param name="url">The URL of the image file to load.</param>
323 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
324 /// <param name="fittingMode">The method used to fit the shape of the image before loading to the shape defined by the size parameter.</param>
325 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
326 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
327 /// <since_tizen> 5 </since_tizen>
328 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
329 [EditorBrowsable(EditorBrowsableState.Never)]
330 public static PixelBuffer DownloadImageSynchronously(string url, Size2D size, FittingModeType fittingMode)
334 throw new ArgumentNullException(nameof(size));
336 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
337 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously(url, Uint16Pair.getCPtr(uSize), (int)fittingMode), true);
338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343 /// Load an image synchronously from a remote resource.
345 /// <param name="url">The URL of the image file to load.</param>
346 /// <param name="size">The width and height to fit the loaded image to, 0.0 means whole image.</param>
347 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
348 /// <exception cref="ArgumentNullException"> Thrown when size is null. </exception>
349 /// <since_tizen> 5 </since_tizen>
350 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
351 [EditorBrowsable(EditorBrowsableState.Never)]
352 public static PixelBuffer DownloadImageSynchronously(string url, Size2D size)
356 throw new ArgumentNullException(nameof(size));
358 var uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
359 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously(url, Uint16Pair.getCPtr(uSize)), true);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365 /// Load an image synchronously from a remote resource.
367 /// <param name="url">The URL of the image file to load.</param>
368 /// <returns>Handle to the loaded PixelBuffer object or an empty handle in case downloading or decoding failed.</returns>
369 /// <since_tizen> 5 </since_tizen>
370 /// This will be released at Tizen.NET API Level 5. Therefore, currently this would be used as an in-house API.
371 [EditorBrowsable(EditorBrowsableState.Never)]
372 public static PixelBuffer DownloadImageSynchronously(string url)
374 PixelBuffer ret = new PixelBuffer(Interop.ImageLoading.DownloadImageSynchronously(url), true);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();