本文整理匯總了C#中MonoMac.AppKit.NSImage.Representations方法的典型用法代碼示例。如果您正苦於以下問題:C# NSImage.Representations方法的具體用法?C# NSImage.Representations怎麽用?C# NSImage.Representations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoMac.AppKit.NSImage
的用法示例。
在下文中一共展示了NSImage.Representations方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Tint
public static NSImage Tint(this NSImage image, NSColor tint)
{
var colorGenerator = new CIConstantColorGenerator
{
Color = CIColor.FromCGColor(tint.CGColor)
};
var colorFilter = new CIColorControls
{
Image = (CIImage)colorGenerator.ValueForKey(CIFilterOutputKey.Image),
Saturation = 3f,
Brightness = 0.35f,
Contrast = 1f
};
var monochromeFilter = new CIColorMonochrome
{
Image = CIImage.FromCGImage(image.CGImage),
Color = CIColor.FromRgb(0.75f, 0.75f, 0.75f),
Intensity = 1f
};
var compositingFilter = new CIMultiplyCompositing
{
Image = (CIImage)colorFilter.ValueForKey(CIFilterOutputKey.Image),
BackgroundImage = (CIImage)monochromeFilter.ValueForKey(CIFilterOutputKey.Image)
};
var outputImage = (CIImage)compositingFilter.ValueForKey(CIFilterOutputKey.Image);
var extent = outputImage.Extent;
var newsize = sd.Size.Truncate(extent.Size);
if (newsize.IsEmpty)
return image;
var tintedImage = new NSImage(newsize);
tintedImage.LockFocus();
try
{
var graphics = NSGraphicsContext.CurrentContext.GraphicsPort;
var ciContext = CIContext.FromContext(graphics, new CIContextOptions { UseSoftwareRenderer = true });
ciContext.DrawImage(outputImage, extent, extent);
}
finally
{
tintedImage.UnlockFocus();
}
var newrep = tintedImage.Representations()[0];
newrep.Size = image.Size;
return tintedImage;
}