Last active
October 6, 2023 11:32
-
-
Save rudyryk/6d2fb109d2df6873e207 to your computer and use it in GitHub Desktop.
Revisions
-
rudyryk renamed this gist
May 9, 2015 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,12 @@ // // ImageMeter.cs // Created by Alexey Kinev on 9 May 2015. // // No Rights Reserved // http://creativecommons.org/publicdomain/zero/1.0/ // // Get image size by name in Xamarin.Forms for iOS and Android platforms. // using System; using Xamarin.Forms; -
rudyryk revised this gist
May 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ namespace Project { public static class ImageMeter { public static Size GetImageSize(string fileName) { -
rudyryk created this gist
May 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ using System; using Xamarin.Forms; #if __IOS__ using UIKit; #endif #if __ANDROID__ using Android.App; using Android.Graphics; using Android.Content.Res; #endif namespace Project { public static class ImageMeasure { public static Size GetImageSize(string fileName) { #if __IOS__ UIImage image = UIImage.FromFile(fileName); return new Size((double)image.Size.Width, (double)image.Size.Height); #endif #if __ANDROID__ var options = new BitmapFactory.Options { InJustDecodeBounds = true }; fileName = fileName.Replace('-', '_').Replace(".png", ""); var resId = Forms.Context.Resources.GetIdentifier( fileName, "drawable", Forms.Context.PackageName); BitmapFactory.DecodeResource( Forms.Context.Resources, resId, options); return new Size((double)options.OutWidth, (double)options.OutHeight); #endif return Size.Zero; } } }