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


C# NSImage.LockFocusFlipped方法代码示例

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


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

示例1: Colourize

		public static void Colourize(NSView control, Color color, Action drawAction)
		{
			var size = control.Frame.Size;
			if (size.Width <= 0 || size.Height <= 0)
				return;
			var image = new NSImage(size);
			
			image.LockFocusFlipped(control.IsFlipped);
			drawAction();
			image.UnlockFocus();
			
			var ciImage = CIImage.FromCGImage(image.CGImage);

			SD.SizeF realSize;
			if (control.RespondsToSelector(selConvertSizeToBacking))
				realSize = control.ConvertSizeToBacking(size);
			else
				realSize = control.ConvertSizeToBase(size);

			if (control.IsFlipped)
			{
				var affineTransform = new NSAffineTransform();
				affineTransform.Translate(0, realSize.Height);
				affineTransform.Scale(1, -1);
				var filter1 = new CIAffineTransform();
				filter1.Image = ciImage;
				filter1.SetValueForKey(affineTransform, CIInputTransform);
				ciImage = filter1.ValueForKey(CIOutputImage) as CIImage;
			}

			var filter2 = new CIColorControls();
			filter2.SetDefaults();
			filter2.Image = ciImage;
			filter2.Saturation = 0.0f;
			ciImage = filter2.ValueForKey(CIOutputImage) as CIImage;
			
			var filter3 = new CIColorMatrix();
			filter3.SetDefaults();
			filter3.Image = ciImage;
			filter3.RVector = new CIVector(0, color.R, 0);
			filter3.GVector = new CIVector(color.G, 0, 0);
			filter3.BVector = new CIVector(0, 0, color.B);
			ciImage = filter3.ValueForKey(CIOutputImage) as CIImage;

			ciImage.Draw(new SD.RectangleF(SD.PointF.Empty, size), new SD.RectangleF(SD.PointF.Empty, realSize), NSCompositingOperation.SourceOver, 1);
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:46,代码来源:MacEventView.cs

示例2: Colourize

		public static void Colourize (NSView control, Color color, Action drawAction)
		{
			var size = control.Frame.Size;
			var image = new NSImage (size);
			
			image.LockFocusFlipped (control.IsFlipped);
			drawAction ();
			image.UnlockFocus ();
			
			var ciImage = CIImage.FromData (image.AsTiff ());
			
			if (control.IsFlipped) {
				var realSize = control.ConvertSizeToBase (size);
				var affineTransform = new NSAffineTransform ();
				affineTransform.Translate (0, realSize.Height);
				affineTransform.Scale (1, -1);
				var filter1 = CIFilter.FromName ("CIAffineTransform");
				filter1.SetValueForKey (ciImage, CIInputImage);
				filter1.SetValueForKey (affineTransform, CIInputTransform);
				ciImage = filter1.ValueForKey (CIOutputImage) as CIImage;
			}
			
			var filter2 = CIFilter.FromName ("CIColorControls");
			filter2.SetDefaults ();
			filter2.SetValueForKey (ciImage, CIInputImage);
			filter2.SetValueForKey (new NSNumber (0.0f), CIInputSaturation);
			ciImage = filter2.ValueForKey (CIOutputImage) as CIImage;
			
			var filter3 = CIFilter.FromName ("CIColorMatrix");
			filter3.SetDefaults ();
			filter3.SetValueForKey (ciImage, CIInputImage);
			filter3.SetValueForKey (new CIVector (0, color.R, 0), CIInputRVector);
			filter3.SetValueForKey (new CIVector (color.G, 0, 0), CIInputGVector);
			filter3.SetValueForKey (new CIVector (0, 0, color.B), CIInputBVector);
			ciImage = filter3.ValueForKey (CIOutputImage) as CIImage;
			
			image = new NSImage (size);
			var rep = NSCIImageRep.FromCIImage (ciImage);
			image.AddRepresentation (rep);
			image.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1);
			/* Use this when implemented in maccore:
			ciImage.Draw (SD.PointF.Empty, new SD.RectangleF (SD.PointF.Empty, size), NSCompositingOperation.SourceOver, 1);
			 */
		}
开发者ID:majorsilence,项目名称:Eto,代码行数:44,代码来源:MacEventView.cs

示例3: Colourize

		public static void Colourize(NSView control, Color color, Action drawAction)
		{
			var size = control.Frame.Size;
			if (size.Width <= 0 || size.Height <= 0)
				return;
			var image = new NSImage(size);
			
			image.LockFocusFlipped(!control.IsFlipped);
			drawAction();
			image.UnlockFocus();

			var ciImage = CIImage.FromCGImage(image.CGImage);

			CGSize realSize;
			if (control.RespondsToSelector(selConvertSizeToBacking))
				realSize = control.ConvertSizeToBacking(size);
			else
				realSize = control.ConvertSizeToBase(size);

			var filter2 = new CIColorControls();
			filter2.SetDefaults();
			filter2.Image = ciImage;
			filter2.Saturation = 0.0f;
			ciImage = (CIImage)filter2.ValueForKey(CIOutputImage);

			var filter3 = new CIColorMatrix();
			filter3.SetDefaults();
			filter3.Image = ciImage;
			filter3.RVector = new CIVector(0, color.R, 0);
			filter3.GVector = new CIVector(color.G, 0, 0);
			filter3.BVector = new CIVector(0, 0, color.B);
			ciImage = (CIImage)filter3.ValueForKey(CIOutputImage);

			// create separate context so we can force using the software renderer, which is more than fast enough for this
			var ciContext = CIContext.FromContext(NSGraphicsContext.CurrentContext.GraphicsPort, new CIContextOptions { UseSoftwareRenderer = true });
			ciContext.DrawImage(ciImage, new CGRect(CGPoint.Empty, size), new CGRect(CGPoint.Empty, realSize));
		}
开发者ID:gene-l-thomas,项目名称:Eto,代码行数:37,代码来源:MacEventView.cs


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