Ejemplo n.º 1
0
		public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize? imageSize = null)
		{
			var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32);
			newrep.Size = imageSize ?? newsize;

			var graphics = NSGraphicsContext.FromBitmap(newrep);
			NSGraphicsContext.GlobalSaveGraphicsState();
			NSGraphicsContext.CurrentContext = graphics;
			graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
			image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, DrawHints);
			NSGraphicsContext.GlobalRestoreGraphicsState();
			return newrep;
		}
Ejemplo n.º 2
0
		public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default)
		{
			var newimage = new NSImage(newsize);
			var newrep = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32);
			newimage.AddRepresentation(newrep);

			var graphics = NSGraphicsContext.FromBitmap(newrep);
			NSGraphicsContext.GlobalSaveGraphicsState();
			NSGraphicsContext.CurrentContext = graphics;
			graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
			image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f);
			NSGraphicsContext.GlobalRestoreGraphicsState();
			return newimage;
		}
Ejemplo n.º 3
0
        public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize?imageSize = null)
        {
            var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32);

            newrep.Size = imageSize ?? newsize;

            var graphics = NSGraphicsContext.FromBitmap(newrep);

            NSGraphicsContext.GlobalSaveGraphicsState();
            NSGraphicsContext.CurrentContext           = graphics;
            graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
            image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, DrawHints);
            NSGraphicsContext.GlobalRestoreGraphicsState();
            return(newrep);
        }
Ejemplo n.º 4
0
        public static NSImage Resize(this NSImage image, sd.Size newsize, ImageInterpolation interpolation = ImageInterpolation.Default)
        {
            var newimage = new NSImage(newsize);
            var newrep   = new NSBitmapImageRep(IntPtr.Zero, newsize.Width, newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * newsize.Width, 32);

            newimage.AddRepresentation(newrep);

            var graphics = NSGraphicsContext.FromBitmap(newrep);

            NSGraphicsContext.GlobalSaveGraphicsState();
            NSGraphicsContext.CurrentContext           = graphics;
            graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
            image.DrawInRect(new sd.RectangleF(sd.PointF.Empty, newimage.Size), new sd.RectangleF(sd.PointF.Empty, image.Size), NSCompositingOperation.SourceOver, 1f);
            NSGraphicsContext.GlobalRestoreGraphicsState();
            return(newimage);
        }
Ejemplo n.º 5
0
        public static NSImageRep Resize(this NSImageRep image, CGSize newsize, ImageInterpolation interpolation = ImageInterpolation.Default, CGSize?imageSize = null)
        {
            var newrep = new NSBitmapImageRep(IntPtr.Zero, (nint)newsize.Width, (nint)newsize.Height, 8, 4, true, false, NSColorSpace.DeviceRGB, 4 * (nint)newsize.Width, 32);

            newrep.Size = imageSize ?? newsize;

            var graphics = NSGraphicsContext.FromBitmap(newrep);

            NSGraphicsContext.GlobalSaveGraphicsState();
            NSGraphicsContext.CurrentContext           = graphics;
            graphics.GraphicsPort.InterpolationQuality = interpolation.ToCG();
#if XAMMAC
            // Xamarin.Mac doesn't allow null for hints, remove this when it does.
            Messaging.bool_objc_msgSend_CGRect_CGRect_UIntPtr_nfloat_bool_IntPtr(image.Handle, selDrawInRect_FromRect_Operation_Fraction_RespectFlipped_Hints_Handle, new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, (UIntPtr)(ulong)NSCompositingOperation.SourceOver, 1f, true, IntPtr.Zero);
#else
            image.DrawInRect(new CGRect(CGPoint.Empty, newrep.Size), CGRect.Empty, NSCompositingOperation.SourceOver, 1f, true, null);
#endif
            NSGraphicsContext.GlobalRestoreGraphicsState();
            return(newrep);
        }