【问题标题】:xamarin ios crop image like Androidxamarin ios 像 Android 一样裁剪图像
【发布时间】:2015-06-24 03:48:20
【问题描述】:
【问题讨论】:
标签:
ios
image
xamarin
crop
【解决方案2】:
float imageWidth = bitmap.Width;
float imageHeight = bitmap.Height;
float width = yourscreenWidth;
float heigth = yourscreenHeight ;
var W= width / heigth / (imageWidth / imageHeight);
var W2 = rect.Width() / widt * W;
var H = rect.Height() / heigth;
var cropImageWidth = imageWidth * W2 ;
var cropImageHeight = imageHeight * H ;
var cropImageX = (imageWidth - cropImageWidth) / 2;
var cropImageY = (imageHeight - cropImageHeight) / 2;
Bitmap imageCropped = Bitmap.CreateBitmap(bitmap, (int)cropImageX, (int)cropImageY,
(int)cropImageWidth, (int)cropImageHeight);