当前位置: 首页>>代码示例>>C#>>正文


C# UIImage.AsPNG方法代码示例

本文整理汇总了C#中UIKit.UIImage.AsPNG方法的典型用法代码示例。如果您正苦于以下问题:C# UIImage.AsPNG方法的具体用法?C# UIImage.AsPNG怎么用?C# UIImage.AsPNG使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIKit.UIImage的用法示例。


在下文中一共展示了UIImage.AsPNG方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderToStream

		public System.IO.Stream RenderToStream (byte[] documentData, int pageIndex)
		{
			using (MemoryStream ms = new MemoryStream (documentData))
			{
				// open document
				using (Document doc = new Document (ms)) 
				{
					// prepare for rendering
					int width = (int)doc.Pages [pageIndex].Width;
					int height = (int)doc.Pages [pageIndex].Height;
					// render the page to a raw bitmap data represented by byte array
					byte[] imageData = ConvertBGRAtoRGBA(doc.Pages [pageIndex].RenderAsBytes (width,height, new RenderingSettings (), null));

					// create CGDataProvider which will serve CGImage creation
					CGDataProvider dataProvider = new CGDataProvider (imageData, 0, imageData.Length);

					// create core graphics image using data provider created above, note that
					// we use CGImageAlphaInfo.Last(ARGB) pixel format
					CGImage cgImage = new CGImage(width,height,8,32,width*4,CGColorSpace.CreateDeviceRGB(),CGImageAlphaInfo.Last,dataProvider,null,false, CGColorRenderingIntent.Default);

					// create UIImage and save it to gallery
					UIImage finalImage = new UIImage (cgImage);
								
					return finalImage.AsPNG ().AsStream();
				}
			}						
		}
开发者ID:apitron,项目名称:Xamarin.Forms.Samples,代码行数:27,代码来源:Renderer.cs

示例2: DidCropToImage

        public override void DidCropToImage(TOCropViewController cropViewController, 
            UIImage image, CoreGraphics.CGRect cropRect, nint angle)
        {
            var imageBytes = image.AsPNG().ToArray();
            _taskCompletionSource.SetResult(imageBytes);

            cropViewController.DismissViewController(true, null);
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:8,代码来源:CropViewControllerDelegate.cs

示例3: SaveTrasnformedImage

 public void SaveTrasnformedImage(UIImage source)
 {
     byte[] myByteArray;
     using (var imageData = source.AsPNG())
     {
         myByteArray = new byte[imageData.Length];
         System.Runtime.InteropServices.Marshal.Copy(imageData.Bytes, myByteArray, 0, Convert.ToInt32(imageData.Length));
     }
     SaveImageLocally(myByteArray, 101);
 }
开发者ID:dimgrek,项目名称:TabbedAppXamarin,代码行数:10,代码来源:SaveImageService.cs

示例4: GetData

 private static NSData GetData(UIImage image, ImageType type, int quality)
 {
     var floatQuality = quality/100f;
     switch(type)
     {
         case ImageType.Jpg:
             return image.AsJPEG(floatQuality);
         case ImageType.Png:
             return image.AsPNG();
         default:
             return image.AsJPEG(floatQuality);
     }
 } 
开发者ID:rsc092020,项目名称:Xamarin.ImageScaling,代码行数:13,代码来源:ImageScalingImplementation.cs

示例5: ImageData

		public ImageData (UIImage image, string filename)
		{
			if (image == null) {
				throw new ArgumentNullException ("image");
			}
			if (string.IsNullOrEmpty (filename)) {
				throw new ArgumentException ("filename");
			}

			Image = image;
			Filename = filename;

			MimeType = (filename.ToLowerInvariant ().EndsWith (".png")) ?
				"image/png" : "image/jpeg";

			if (MimeType == "image/png") {
				Data = new NSDataStream (image.AsPNG ());
			}
			else {
				Data = new NSDataStream (image.AsJPEG ());
			}
		}
开发者ID:nissan,项目名称:Xamarin.Social,代码行数:22,代码来源:ImageData.cs

示例6: DidCropToImage

		public override void DidCropToImage (TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle)
		{
			DidCrop = true;

			try 
			{
				if (image != null)
					App.CroppedImage = image.AsPNG().ToArray();

			}
			catch (Exception ex) {
				Debug.WriteLine (ex.Message);
			}
			finally
			{
				if (image != null) {
					image.Dispose ();
					image = null;
				}
			}

			parent.DismissViewController (true, App.PopModal);
		}
开发者ID:BradleyDHobbs,项目名称:Xamarin.CropView,代码行数:23,代码来源:CropViewDelegate.cs

示例7: GetImageStream

        private static Stream GetImageStream(UIImage image, ImageFormatType formatType)
        {
            if (formatType == ImageFormatType.Jpg)
                return image.AsJPEG().AsStream();

            return image.AsPNG().AsStream();
        }
开发者ID:mrbelk,项目名称:acr-xamarin-forms,代码行数:7,代码来源:SignatureServiceController.cs

示例8: UIImageToByteArray

		// Parse UIImage to Byte[]
		public static byte[] UIImageToByteArray (UIImage _image)
		{ 
			Byte[] byteArray; 
			using (NSData nsImageData = _image.AsPNG ()) { 
				byteArray = new Byte[nsImageData.Length]; 
				System.Runtime.InteropServices.Marshal.Copy (nsImageData.Bytes, byteArray, 0, Convert.ToInt32 (nsImageData.Length)); 
			} 

			return byteArray; 
		}
开发者ID:borain89vn,项目名称:demo2,代码行数:11,代码来源:MUtils.cs

示例9: SetGeneratedImageAsync

		public async Task SetGeneratedImageAsync (string key, UIImage uiImage, bool saveToDisk = true)
		{
			if (uiImage == null) {
				RemoveImage (key);
				return;
			}

			//
			// Does it already exist in memory?
			//
			SetMemoryImage (key, uiImage, DateTime.UtcNow);

			//
			// If we added it to memory, then save it to disk
			//
			if (saveToDisk) {
				await Task.Run (() => {
					FileSystemManager.EnsureDirectoryExists (cacheDirectory);
					var cachePath = GetCachePath (key);
					NSError err;
					uiImage.AsPNG ().Save (cachePath, false, out err);
					if (err != null) {
						Debug.WriteLine (err);
					}
				});
			}
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:27,代码来源:ImageCache.cs

示例10: DidOutputImage

 public override void DidOutputImage(BlinkID blinkid, UIImage image, string name)
 {
     MessagingCenter.Send (new Messages.BlinkIDImage {
         Image = ImageSource.FromStream (() => image.AsPNG ().AsStream ())
     }, Messages.BlinkIDImageMessage);
 }
开发者ID:BlinkID,项目名称:blinkid-xamarin,代码行数:6,代码来源:BlinkIDImplementation.cs


注:本文中的UIKit.UIImage.AsPNG方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。