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


C# NSImage.AsCGImage方法代码示例

本文整理汇总了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);
		}
开发者ID:RafasTavares,项目名称:mac-samples,代码行数:31,代码来源:Texture.cs

示例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 ();
			}
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:22,代码来源:GtkMacDesktopBackend.cs

示例3: ESTexture2D

 public ESTexture2D(NSImage nsImage, All filter)
 {
     // TODO InitWithCGImage(nsImage,filter);
     CGImage image = nsImage.AsCGImage (RectangleF.Empty, null, null);
     InitWithCGImage (image, filter);
 }
开发者ID:JoelCarter,项目名称:MonoGame,代码行数:6,代码来源:ESTexture2D.cs

示例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
 }
开发者ID:anton-nesterenko,项目名称:CrossGraphics,代码行数:9,代码来源:CoreGraphicsGraphics.cs

示例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);
        }
开发者ID:adamhathcock,项目名称:comictoolx,代码行数:10,代码来源:MainWindowController.cs


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