[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetClosestImageSize__SWIG_4")]
public static extern global::System.IntPtr GetClosestImageSize__SWIG_4(string jarg1);
- [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetOriginalImageSize")]
- public static extern global::System.IntPtr GetOriginalImageSize(string jarg1);
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetOriginalImageSize__SWIG_0")]
+ public static extern global::System.IntPtr GetOriginalImageSize_SWIG_0(string jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetOriginalImageSize__SWIG_1")]
+ public static extern global::System.IntPtr GetOriginalImageSize_SWIG_1(string jarg1, bool jarg2);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_DownloadImageSynchronously__SWIG_0")]
public static extern global::System.IntPtr DownloadImageSynchronously__SWIG_0(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, int jarg3, int jarg4, bool jarg5);
{
if(_resourceUrl != null)
{
- Size2D desiredSize = new Size2D(_desired_width,_desired_height);
- Size2D imageSize = ImageLoading.GetClosestImageSize(_resourceUrl, desiredSize, FittingModeType.ScaleToFill);
- temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue((int)imageSize.Width));
- temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue((int)imageSize.Height));
+ Size2D imageSize = ImageLoading.GetOriginalImageSize(_resourceUrl,true);
+
+ int adjustedDesiredWidth, adjustedDesiredHeight;
+ float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
+ float aspectOfImageSize = (float)imageSize.Height / (float)imageSize.Width;
+ if( aspectOfImageSize > aspectOfDesiredSize)
+ {
+ adjustedDesiredWidth = _desired_width;
+ adjustedDesiredHeight = imageSize.Height * _desired_width / imageSize.Width;
+ }
+ else
+ {
+ adjustedDesiredWidth = imageSize.Width * _desired_height/ imageSize.Height;
+ adjustedDesiredHeight = _desired_height;
+ }
+ temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue(adjustedDesiredWidth));
+ temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue(adjustedDesiredHeight));
temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int) FittingModeType.ScaleToFill));
}
}
}
/// <summary>
- /// Get the size of an original image
+ /// Get the size of an original image. this method will not respect any rotation of image
/// </summary>
/// <param name="filename">The name of the image.</param>
/// <returns>Dimension of the original image.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static Size2D GetOriginalImageSize(string filename)
{
- var val = new Uint16Pair(Interop.ImageLoading.GetOriginalImageSize(filename), true);
+ var val = new Uint16Pair(Interop.ImageLoading.GetOriginalImageSize_SWIG_0(filename), true);
+ Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ /// <summary>
+ /// Get the size of an original image consider rotation
+ /// </summary>
+ /// <param name="filename">The name of the image.</param>
+ /// <param name="orientationCorrection">Reorient the image to respect any orientation metadata in its header.</param>
+ /// <returns>Dimension of the original image.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be released at Tizen.NET API Level 9. Therefore, currently this would be used as an in-house API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static Size2D GetOriginalImageSize(string filename, bool orientationCorrection )
+ {
+ var val = new Uint16Pair(Interop.ImageLoading.GetOriginalImageSize_SWIG_1(filename,orientationCorrection), true);
Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;