IOS UIImage Imagen al revés

if i draw my image I fixed the problem use 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);

when i wanna write to file i use this

 NSData *imageData = UIImageJPEGRepresentation(backImage, 0);  

then Image upside down how ?

preguntado el 31 de julio de 12 a las 13:07

Where do you get the backImage from? Can't you just flip the context there using a transform once? -

i draw it ,like CGContextBeginPath.... CGContextMove..(0,0) CGContextAddLines....CGContextFillPath..... -

2 Respuestas

When you want to get a UIImage to save, use:

UIGraphicsBeginImageContextWithOptions(size, isOpaque, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, (CGRect){ {0,0}, origSize }, [origImage CGImage]);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;

Entonces hazlo:

 NSData *imageData = UIImageJPEGRepresentation(backImage, 0);

Respondido 31 Jul 12, 15:07

Apple tells us over and over again at WWDC to use the above when rendering images. - David H

First make Identity matrix.

1, 0, 0
0, 1, 0
0, 0, 1

CGAffineTransform matrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);

Move position for drawing...

matrix = CGAffineTransformTranslate(matrix, x, y);

Flip matrix horizontal.

matrix = CGAffineTransformScale(matrix, -1, 1);

Flip matrix vertical.

matrix = CGAffineTransformScale(matrix, 1, -1);

Rotate matrix

matrix = CGAffineTransformRotate(matrix, angle);

Fit scale UIImage to UIView.

matrix = CGAffineTransformScale(matrix, imageWidth/viewWidth, imageheight/viewHeight);

Launch matrix into the context.

CGContextConcatCTM(context, matrix);

Draw image.

[backImage drawAtPoint:CGPointMake(0, 0)];

:)

Respondido 13 Feb 14, 16:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.