當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。