나는 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