0
iOS-Appでこれまでと同じように、自分のMac-Appで画像のサイズを変更しようとしています。問題は、NSImageにUIImageが行うすべてのメソッドが含まれていないことです。ここでiOSで使用したコードはXamarin Mac - サイズ変更Image
public static UIImage MaxResizeImage(this UIImage sourceImage, float maxWidth, float maxHeight)
{
var sourceSize = sourceImage.Size;
var maxResizeFactor = Math.Max(maxWidth/sourceSize.Width, maxHeight/sourceSize.Height);
if (maxResizeFactor > 1) return sourceImage;
float width = (float)(maxResizeFactor * sourceSize.Width);
float height = (float)(maxResizeFactor * sourceSize.Height);
UIGraphics.BeginImageContext(new SizeF(width, height));
sourceImage.Draw(new RectangleF(0, 0, width, height));
var resultImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return resultImage;
}
Mac-Appの場合はどのように書き直すことができますか?あなたの助けをありがとう
解決しない場合は、anwserを受け入れるかコメントを追加してください – svn