本文整理汇总了C#中Xwt.Backends.ImageDescription.ToNSImage方法的典型用法代码示例。如果您正苦于以下问题:C# ImageDescription.ToNSImage方法的具体用法?C# ImageDescription.ToNSImage怎么用?C# ImageDescription.ToNSImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Backends.ImageDescription
的用法示例。
在下文中一共展示了ImageDescription.ToNSImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public override object Create(ImageDescription img)
{
NSImage nimg = img.ToNSImage ();
return new ImagePatternInfo () {
Image = nimg
};
}
示例2: DrawImage
public override void DrawImage(object backend, ImageDescription img, Rectangle srcRect, Rectangle destRect)
{
CGContext ctx = ((CGContextBackend)backend).Context;
NSImage image = img.ToNSImage ();
ctx.SaveState ();
ctx.SetAlpha ((float)img.Alpha);
double rx = destRect.Width / srcRect.Width;
double ry = destRect.Height / srcRect.Height;
ctx.AddRect (new RectangleF ((float)destRect.X, (float)destRect.Y, (float)destRect.Width, (float)destRect.Height));
ctx.Clip ();
ctx.TranslateCTM ((float)(destRect.X - (srcRect.X * rx)), (float)(destRect.Y - (srcRect.Y * ry)));
ctx.ScaleCTM ((float)rx, (float)ry);
if (image is CustomImage) {
((CustomImage)image).DrawInContext ((CGContextBackend)backend);
} else {
RectangleF rr = new RectangleF (0, 0, (float)image.Size.Width, image.Size.Height);
ctx.ScaleCTM (1f, -1f);
ctx.DrawImage (new RectangleF (0, -image.Size.Height, image.Size.Width, image.Size.Height), image.AsCGImage (ref rr, NSGraphicsContext.CurrentContext, null));
}
ctx.RestoreState ();
}
示例3: SetImage
public void SetImage (ImageDescription image)
{
item.Image = image.ToNSImage ();
}