本文整理汇总了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();
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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 ());
}
}
示例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);
}
示例7: GetImageStream
private static Stream GetImageStream(UIImage image, ImageFormatType formatType)
{
if (formatType == ImageFormatType.Jpg)
return image.AsJPEG().AsStream();
return image.AsPNG().AsStream();
}
示例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;
}
示例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);
}
});
}
}
示例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);
}