如果我画我的形象我固定的问题使用CGAffintrasform
CGAffineTransform myTr = CGAffineTransformMake(1, 0, 0, -1, 0, backImage.size.height);
CGContextConcatCTM(context, myTr);
[backImage drawInRect:CGRectMake(cbx, -cby, backImage.size.width, backImage.size.height)];
myTr = CGAffineTransformMake(1, 0, 0, -1, 0, backImage.size.height);
CGContextConcatCTM(context, myTr);
当我想写入文件我用这个
NSData *imageData = UIImageJPEGRepresentation(backImage, 0);
然后图像上下颠倒怎么样?
如果你想获得一个UIImage保存,使用方法:
UIGraphicsBeginImageContextWithOptions(size, isOpaque, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, (CGRect){ {0,0}, origSize }, [origImage CGImage]);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
然后做:
NSData *imageData = UIImageJPEGRepresentation(backImage, 0);
首先要识别矩阵。
1, 0, 0
0, 1, 0
0, 0, 1
CGAffineTransform matrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
移动位置绘制...
matrix = CGAffineTransformTranslate(matrix, x, y);
翻转矩阵水平。
matrix = CGAffineTransformScale(matrix, -1, 1);
翻转矩阵垂直。
matrix = CGAffineTransformScale(matrix, 1, -1);
旋转矩阵
matrix = CGAffineTransformRotate(matrix, angle);
适合大规模的UIImage到UIView的。
matrix = CGAffineTransformScale(matrix, imageWidth/viewWidth, imageheight/viewHeight);
启动基质进入环境。
CGContextConcatCTM(context, matrix);
绘制图像。
[backImage drawAtPoint:CGPointMake(0, 0)];
:)