Esq*_*uth 0 crop objective-c uiimage ios
我想在对它进行像素操作之前裁剪UIImage(不是imageview).在ios框架中有可靠的方法吗?
以下是我正在使用的android中的相关方法:
http://developer.android.com/reference/android/graphics/Bitmap.html#createBitmap(android.graphics.Bitmap,INT,INT,INT,INT) http://developer.android.com/reference/android/ graphics/Bitmap.html #createBitmap(int,int,android.graphics.Bitmap.Config)
-(UIImage*)scaleToSize:(CGSize)size image:(UIImage*)image
{
UIGraphicsBeginImageContext(size);
// Draw the scaled image in the current context
[image 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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
310 次 |
| 最近记录: |