UIImagepicker setEditingをYesメソッド(またはカメラアプリのように)を使ってカメラで撮影するときと同様に、写真ライブラリからユーザーが触れた画像を縮小しようとしています。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にあなたの呼び出しに固定値を入れてみましたがありますか?現時点でどのような結果が得られますか? –
私は修正値を追加して、修正値で動作します。問題はあまり値ではありません。 – hemant