Ejemplo n.º 1
0
 public override object Create(ImageDescription img)
 {
     NSImage nimg = img.ToNSImage ();
     return new ImagePatternInfo () {
         Image = nimg
     };
 }
Ejemplo n.º 2
0
        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 ();
        }
Ejemplo n.º 3
0
		public void SetImage (ImageDescription image)
		{
			item.Image = image.ToNSImage ();
		}