MonoTouch.Dialog.ImageElement.Scale C# (CSharp) Method

Scale() private method

private Scale ( UIImage source ) : UIImage
source UIImage
return UIImage
        UIImage Scale(UIImage source)
        {
            UIGraphics.BeginImageContext (new SizeF (dimx, dimy));
            var ctx = UIGraphics.GetCurrentContext ();

            var img = source.CGImage;
            ctx.TranslateCTM (0, dimy);
            if (img.Width > img.Height)
                ctx.ScaleCTM (1, -img.Width/dimy);
            else
                ctx.ScaleCTM (img.Height/dimx, -1);

            ctx.DrawImage (rect, source.CGImage);

            var ret = UIGraphics.GetImageFromCurrentImageContext ();
            UIGraphics.EndImageContext ();
            return ret;
        }