UIImage*imgStorage = [self resizeImage:imgStorage2];
-(UIImage *)resizeImage:(UIImage *)image {
int width, height;
width = 300;
int w_porcentaje = ((width*100)/image.size.width);
int h = ((image.size.height*w_porcentaje)/100);
height=h;
CGImageRef imageRef = [image CGImage];
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
//if (alphaInfo == kCGImageAlphaNone)
alphaInfo = kCGImageAlphaNoneSkipLast;
CGContextRef bitmap = CGBitmapContextCreate(NULL, 300, 200, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo);
CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef);
CGImageRef ref = CGBitmapContextCreateImage(bitmap);
UIImage *result = [UIImage imageWithCGImage:ref];
CGContextRelease(bitmap);
CGImageRelease(ref);
return result;
}
No hay comentarios:
Publicar un comentario