这是模糊的图像和代码,希望有人有一些想法:)
UIGraphics.BeginImageContext (new Sizef(150,150));var context = UIGraphics.GetCurrentContext ();var content = "CIRCLE";var Font = UIFont.SystemFontOfSize (16);const float wIDth = 150;const float height = 150;context.SetFillcolorWithcolor (UIcolor.Red.CGcolor);context.FillEllipseInRect (new RectangleF (0,wIDth,height));var contentString = new Nsstring (content);var contentSize = contentString.StringSize (Font);var rect = new RectangleF (0,((height - contentSize.Height) / 2) + 0,contentSize.Height);context.SetFillcolorWithcolor (UIcolor.White.CGcolor);new Nsstring (content).DrawString (rect,Font,UIlineBreakMode.WorDWrap,UITextAlignment.Center);var image = UIGraphics.GetimageFromCurrentimageContext ();imageVIEw.Image = image;解决方法 它模糊的原因是因为它被调整了大小.该位图不是150×150(就像你创建的上下文一样),它是333×317像素.
这可能是因为imageVIEw正在缩放它的图像(没有源代码)或因为像素加倍(用于视网膜显示).在后一种情况下,您真正想要使用的是:
UIGraphics.BeginImageContextWithOptions (size,false,0);
将(使用0)自动使用正确的视网膜(或不显示)缩放因子 – 并且在所有类型的设备上看起来都很清晰(而不是过大).
总结以上是内存溢出为你收集整理的IOS绘制一个简单的图像变得模糊使用Xamarin C#全部内容,希望文章能够帮你解决IOS绘制一个简单的图像变得模糊使用Xamarin C#所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)