1
我想缩小图片我从用户touchesmoved从照片库中获得类似的方式,如当我们用相机使用UIImagepicker setEditing到的方法(或像相机应用程序)拍照时。在iPhone中从照片库中缩放并保存UIImage?
我想使用下面的方法传递一些基于touchesmoved的参数,但我没有得到所需的效果?我可能做错了什么?
-(UIImage*)scaleToSize:(UIImage *)img:(CGSize)size
{
// Create a bitmap graphics context
// This will also set it as the current context
UIGraphicsBeginImageContext(size);
// Draw the scaled image in the current context
[img drawInRect:CGRectMake(0, 0, size.width, size.height)];
// Create a new image from current context
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
// Pop the current context from the stack
UIGraphicsEndImageContext();
// Return our new scaled image
return scaledImage;
}
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UIImage *img = [self scaleToSize:imgView.image:CGSizeMake(touch1.x,touch1.y)];
imgView.image=img;
}
另外我怎样才能保存缩放后的图像一次以某种方式我缩放?
你有没有试图把固定值到您的来电scaleToSize:IMG:以检查它是否是你接触逻辑不正确或你的方法是什么?你现在得到什么结果? – 2012-01-10 08:48:39
我已添加修复值,它与修复值一起工作..问题不是很多值我给任何值扭曲的图像,而不是缩放它 – hemant 2012-01-10 09:21:33