本文整理汇总了C#中MonoMac.AppKit.NSImage.AsCGImage方法的典型用法代码示例。如果您正苦于以下问题:C# NSImage.AsCGImage方法的具体用法?C# NSImage.AsCGImage怎么用?C# NSImage.AsCGImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.AppKit.NSImage
的用法示例。
在下文中一共展示了NSImage.AsCGImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImagaDataFromPath
void GetImagaDataFromPath (string path)
{
NSImage src;
CGImage image;
CGContext context = null;
src = new NSImage (path);
var rect = RectangleF.Empty;
image = src.AsCGImage (ref rect, null, null);
width = image.Width;
height = image.Height;
data = new byte[width * height * 4];
CGImageAlphaInfo ai = CGImageAlphaInfo.PremultipliedLast;
context = new CGBitmapContext (data, width, height, 8, 4 * width, image.ColorSpace, ai);
// Core Graphics referential is upside-down compared to OpenGL referential
// Flip the Core Graphics context here
// An alternative is to use flipped OpenGL texture coordinates when drawing textures
context.TranslateCTM (0, height);
context.ScaleCTM (1, -1);
// Set the blend mode to copy before drawing since the previous contents of memory aren't used.
// This avoids unnecessary blending.
context.SetBlendMode (CGBlendMode.Copy);
context.DrawImage (new RectangleF (0, 0, width, height), image);
}
示例2: GetPixbufFromNSImage
public static Gdk.Pixbuf GetPixbufFromNSImage (NSImage icon, int width, int height)
{
var rect = new RectangleF (0, 0, width, height);
var rep = icon.BestRepresentation (rect, null, null);
var bitmap = rep as NSBitmapImageRep;
try {
if (bitmap == null) {
if (rep != null)
rep.Dispose ();
using (var cgi = icon.AsCGImage (ref rect, null, null)) {
if (cgi == null)
return null;
bitmap = new NSBitmapImageRep (cgi);
}
}
return GetPixbufFromNSBitmapImageRep (bitmap, width, height);
} finally {
if (bitmap != null)
bitmap.Dispose ();
}
}
示例3: ESTexture2D
public ESTexture2D(NSImage nsImage, All filter)
{
// TODO InitWithCGImage(nsImage,filter);
CGImage image = nsImage.AsCGImage (RectangleF.Empty, null, null);
InitWithCGImage (image, filter);
}
示例4: ImageFromFile
public IImage ImageFromFile(string filename)
{
#if MONOMAC
var img = new NSImage ("Images/" + filename);
return new UIKitImage (img.AsCGImage (new RectangleF (PointF.Empty, img.Size), NSGraphicsContext.CurrentContext, new MonoMac.Foundation.NSDictionary ()));
#else
return new UIKitImage (UIImage.FromFile ("Images/" + filename).CGImage);
#endif
}
示例5: LoadCurrentEntry
public void LoadCurrentEntry()
{
var nsImage = new NSImage (NSData.FromArray (comic.CurrentPage.Bytes));
var image = nsImage.AsCGImage (RectangleF.Empty, null, null);
imageView.SetImageimageProperties (image, new NSDictionary ());
imageView.ZoomImageToFit (this);
CalculateAndSet();
imageView.ZoomImageToFit (this);
}