CGImageRef의 크기를 조정하려고하므로 원하는 크기로 화면에 그릴 수 있습니다. 그래서이 코드가 있습니다 코어 그래픽의 이미지 크기 조정
CGColorSpaceRef colorspace = CGImageGetColorSpace(originalImage);
CGContextRef context = CGBitmapContextCreate(NULL,
CGImageGetWidth(originalImage),
CGImageGetHeight(originalImage),
CGImageGetBitsPerComponent(originalImage),
CGImageGetBytesPerRow(originalImage),
colorspace,
CGImageGetAlphaInfo(originalImage));
if(context == NULL)
return nil;
CGRect clippedRect = CGRectMake(CGContextGetClipBoundingBox(context).origin.x,
CGContextGetClipBoundingBox(context).origin.y,
toWidth,
toHeight);
CGContextClipToRect(context, clippedRect);
// draw image to context
CGContextDrawImage(context, clippedRect, originalImage);
// extract resulting image from context
CGImageRef imgRef = CGBitmapContextCreateImage(context);
그래서이 코드는 나를 분명히 내가 원하는 크기로 이미지를 그릴 수를, 그것은 좋다. 문제는 실제로 크기가 조정되지 않은 화면에서 크기가 조정 된 것처럼 보이지만 한 번 크기가 조절되는 실제 이미지입니다. 내가 할 때 :
CGImageGetWidth (imgRef);
실제로 화면의 너비가 아니라 이미지의 원래 너비를 반환합니다.
그래서 실제로 실제로 크기가 조정되고 원하는 크기로 그려지는 이미지를 실제로 만들 수 있습니까 ??
감사
* 크기를 변경 하시겠습니까? 아니면 크기를 조정 하시겠습니까? 두 번째 작업을 수행하지 않고 첫 번째 작업을 수행 할 수 있습니다. (더 빨라질 것입니다.) – Robin