Estoy intentando cambiar el tamaño de una imagen cargada desde el disco - un JPG o PNG (no sé el formato cuando lo cargo) - y luego guardarlo de nuevo en el disco.Cambiar el tamaño y guardar una imagen en el disco en Monotouch
Tengo el siguiente código que he tratado de portar desde Object-C, sin embargo, me he quedado atascado en las últimas partes. Original Objective-C.
Puede que esta no sea la mejor manera de lograr lo que quiero hacer, cualquier solución está bien para mí.
int width = 100;
int height = 100;
using (UIImage image = UIImage.FromFile(filePath))
{
CGImage cgimage = image.CGImage;
CGImageAlphaInfo alphaInfo = cgimage.AlphaInfo;
if (alphaInfo == CGImageAlphaInfo.None)
alphaInfo = CGImageAlphaInfo.NoneSkipLast;
CGBitmapContext context = new CGBitmapContext(IntPtr.Zero,
width,
height,
cgimage.BitsPerComponent,
4 * width,
cgimage.ColorSpace,
alphaInfo);
context.DrawImage(new RectangleF(0, 0, width, height), cgimage);
/*
Not sure how to convert this part:
CGImageRef ref = CGBitmapContextCreateImage(bitmap);
UIImage* result = [UIImage imageWithCGImage:ref];
CGContextRelease(bitmap); // ok if NULL
CGImageRelease(ref);
*/
}