Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios 我在monotouch中使用以下缩放图像的代码,但它不能保持图像的质量 公共静态类ImageHelper { 公共静态UIImage缩放(UIImage源,SizeF newSize) { UIGraphics.BeginImageContext(新闻大小); var context=UIGraphics.GetCurrentContext(); context.InterpolationQuality=cgipolationquality.High; context.TranslateCTM(0,newSize.Height); context.ScaleCTM(1f,-1f); context.DrawImage(新矩形F(0,0,newSize.Width,newSize.Height),source.CGImage); var scaleImage=UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); 返回缩放图像; } 公共静态UIImage旋转(UIImage图像) { 图像分辨率; 使用(cgimageImageRef=image.CGImage){ CGImageAlphaInfo alphaInfo=imageRef.alphaInfo; CGColorSpace colorspace info=CGColorSpace.CreateDeviceRGB(); if(alphaInfo==CGImageAlphaInfo.None){ alphaInfo=CGImageAlphaInfo.NoneSkipLast; } int宽度、高度; 宽度=图像参考宽度; 高度=图像参考高度; int maxSize=Math.Max(宽度、高度); 如果(高度>=宽度){ 宽度=(int)数学地板((双)宽度*((双)最大尺寸/(双)高度)); 高度=最大尺寸; }否则{ 高度=(int)数学地板((双)高*((双)最大尺寸/(双)宽度)); 宽度=最大尺寸; } CGBitmapContext位图; if(image.Orientation==UIImageOrientation.Up | | image.Orientation==UIImageOrientation.Down){ 位图=新的CGBitmapContext(IntPtr.Zero、宽度、高度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); }否则{ 位图=新的CGBitmapContext(IntPtr.Zero、高度、宽度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); } 开关(图像方向){ 案例UIImageOrientation。左: bitmap.RotateCTM((float)Math.PI/2); 位图.TranslateCTM(0,-高度); 打破 案例UIImageOrientation。右: bitmap.RotateCTM(-(float)Math.PI/2)); bitmap.TranslateCTM(-width,0); 打破 案例UIImageOrientation.Up: 打破 案例UIImageOrientation.Down: 位图.TranslateCTM(宽度、高度); bitmap.RotateCTM(-(float)Math.PI); 打破 } 位图.DrawImage(新矩形(0,0,宽度,高度),imageRef); res=UIImage.FromImage(bitmap.ToImage()); 位图=空; } 返回res; } }_Xamarin.ios - Fatal编程技术网

Xamarin.ios 我在monotouch中使用以下缩放图像的代码,但它不能保持图像的质量 公共静态类ImageHelper { 公共静态UIImage缩放(UIImage源,SizeF newSize) { UIGraphics.BeginImageContext(新闻大小); var context=UIGraphics.GetCurrentContext(); context.InterpolationQuality=cgipolationquality.High; context.TranslateCTM(0,newSize.Height); context.ScaleCTM(1f,-1f); context.DrawImage(新矩形F(0,0,newSize.Width,newSize.Height),source.CGImage); var scaleImage=UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); 返回缩放图像; } 公共静态UIImage旋转(UIImage图像) { 图像分辨率; 使用(cgimageImageRef=image.CGImage){ CGImageAlphaInfo alphaInfo=imageRef.alphaInfo; CGColorSpace colorspace info=CGColorSpace.CreateDeviceRGB(); if(alphaInfo==CGImageAlphaInfo.None){ alphaInfo=CGImageAlphaInfo.NoneSkipLast; } int宽度、高度; 宽度=图像参考宽度; 高度=图像参考高度; int maxSize=Math.Max(宽度、高度); 如果(高度>=宽度){ 宽度=(int)数学地板((双)宽度*((双)最大尺寸/(双)高度)); 高度=最大尺寸; }否则{ 高度=(int)数学地板((双)高*((双)最大尺寸/(双)宽度)); 宽度=最大尺寸; } CGBitmapContext位图; if(image.Orientation==UIImageOrientation.Up | | image.Orientation==UIImageOrientation.Down){ 位图=新的CGBitmapContext(IntPtr.Zero、宽度、高度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); }否则{ 位图=新的CGBitmapContext(IntPtr.Zero、高度、宽度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); } 开关(图像方向){ 案例UIImageOrientation。左: bitmap.RotateCTM((float)Math.PI/2); 位图.TranslateCTM(0,-高度); 打破 案例UIImageOrientation。右: bitmap.RotateCTM(-(float)Math.PI/2)); bitmap.TranslateCTM(-width,0); 打破 案例UIImageOrientation.Up: 打破 案例UIImageOrientation.Down: 位图.TranslateCTM(宽度、高度); bitmap.RotateCTM(-(float)Math.PI); 打破 } 位图.DrawImage(新矩形(0,0,宽度,高度),imageRef); res=UIImage.FromImage(bitmap.ToImage()); 位图=空; } 返回res; } }

Xamarin.ios 我在monotouch中使用以下缩放图像的代码,但它不能保持图像的质量 公共静态类ImageHelper { 公共静态UIImage缩放(UIImage源,SizeF newSize) { UIGraphics.BeginImageContext(新闻大小); var context=UIGraphics.GetCurrentContext(); context.InterpolationQuality=cgipolationquality.High; context.TranslateCTM(0,newSize.Height); context.ScaleCTM(1f,-1f); context.DrawImage(新矩形F(0,0,newSize.Width,newSize.Height),source.CGImage); var scaleImage=UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); 返回缩放图像; } 公共静态UIImage旋转(UIImage图像) { 图像分辨率; 使用(cgimageImageRef=image.CGImage){ CGImageAlphaInfo alphaInfo=imageRef.alphaInfo; CGColorSpace colorspace info=CGColorSpace.CreateDeviceRGB(); if(alphaInfo==CGImageAlphaInfo.None){ alphaInfo=CGImageAlphaInfo.NoneSkipLast; } int宽度、高度; 宽度=图像参考宽度; 高度=图像参考高度; int maxSize=Math.Max(宽度、高度); 如果(高度>=宽度){ 宽度=(int)数学地板((双)宽度*((双)最大尺寸/(双)高度)); 高度=最大尺寸; }否则{ 高度=(int)数学地板((双)高*((双)最大尺寸/(双)宽度)); 宽度=最大尺寸; } CGBitmapContext位图; if(image.Orientation==UIImageOrientation.Up | | image.Orientation==UIImageOrientation.Down){ 位图=新的CGBitmapContext(IntPtr.Zero、宽度、高度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); }否则{ 位图=新的CGBitmapContext(IntPtr.Zero、高度、宽度、imageRef.BitsPerComponent、imageRef.BytesPerRow、colorSpaceInfo、alphaInfo); } 开关(图像方向){ 案例UIImageOrientation。左: bitmap.RotateCTM((float)Math.PI/2); 位图.TranslateCTM(0,-高度); 打破 案例UIImageOrientation。右: bitmap.RotateCTM(-(float)Math.PI/2)); bitmap.TranslateCTM(-width,0); 打破 案例UIImageOrientation.Up: 打破 案例UIImageOrientation.Down: 位图.TranslateCTM(宽度、高度); bitmap.RotateCTM(-(float)Math.PI); 打破 } 位图.DrawImage(新矩形(0,0,宽度,高度),imageRef); res=UIImage.FromImage(bitmap.ToImage()); 位图=空; } 返回res; } },xamarin.ios,Xamarin.ios,调用方法=>UIImage ScaledImage=ImageHelper.Scale(ImageHelper.Rotate(downloadedImage),newsizef(270260)) 请提供任何解决方案来保持质量,并将其扩展到所需的大小。Xamarin的实现包含两种不同的scale()方法 Xamarin的实现包含两种不同的Scale()方法 尝试使用CoreGraphics而不是UIKit重新缩放顺便说一下,Monotouch的UIImage已经有了缩放方法。尝试使用CoreGra

调用方法=>
UIImage ScaledImage=ImageHelper.Scale(ImageHelper.Rotate(downloadedImage),newsizef(270260))

请提供任何解决方案来保持质量,并将其扩展到所需的大小。

Xamarin的实现包含两种不同的scale()方法

Xamarin的实现包含两种不同的Scale()方法


尝试使用
CoreGraphics
而不是
UIKit
重新缩放顺便说一下,Monotouch的UIImage已经有了缩放方法。尝试使用
CoreGraphics
而不是
UIKit
重新缩放顺便说一句,Monotouch的UIImage已经有了缩放方法。
Scale(System.Drawing.SizeF) : UIImage
Scale(System.Drawing.SizeF, float) : UIImage