"景先生毕设|www.jxszl.com

C# CGBitmapContext类代码示例

2023-12-29 17:42编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中CGBitmapContext类的典型用法代码示例。如果您正苦于以下问题:C#CGBitmapContext类的具体用法?C#CGBitmapContext怎么用?C#CGBitmapContext使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:ResizeImageIOS publicbyte[]ResizeImageIOS(byte[]imageData,floatsize) { UIImageoriginalImage=ImageFromByteArray(imageData); System.Diagnostics.Debug.Write("originalImage.Size.Height"+originalImage.Size.Height+","+originalImage.Size.Width); UIImageOrientationorientation=originalImage.Orientation; floatwidth=size; floatheight=((float)originalImage.Size.Height/(float)originalImage.Size.Width)*size; System.Diagnostics.Debug.Write("newsize"+width+","+height); //createa24bitRGBimage using(CGBitmapContextcontext=newCGBitmapContext(IntPtr.Zero, (int)width,(int)height,8, (int)(4*width),CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleFimageRect=newRectangleF(0,0,width,height); //drawtheimage context.DrawImage(imageRect,originalImage.CGImage); UIKit.UIImageresizedImage=UIKit.UIImage.FromImage(context.ToImage(),0,orientation); //savetheimageasajpeg returnresizedImage.AsJPEG().ToArray(); } }
原文链接:http://www.jxszl.com/biancheng/C/556710.html