Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习UIImage在 iOS 上使用 Objective-C 对 s 进行基本操作。假设我有一个 128x128 的正方形图像。如何裁剪图像的下半部分并将上半部分存储在 128x64 图像中?
UIImage
你要做的是从 UIImage 的 CGImage 中得到一个更小的 CGImageRef:
CGImageCreateWithImageInRect([image CGImage], someRect);
使用该图像,您可以创建一个新图像:
UIImage *nImage = [UIImage alloc] initWithCGImage:nImageRef];
糟糕,几乎忘记了,在您执行上述操作后:
CGImageRelease(nImageRef);