2010-05-04 9 views
1

Ceci est ma méthode drawInContext:Pourquoi mon image est à l'envers?

UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"png"]]; 
CGRect cropRect = CGRectMake(0, 0, 175, 175); 
CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], cropRect); 

CGRect imageRect; 

imageRect.origin = CGPointMake(0, 0); 
imageRect.size = CGSizeMake(175, 175); 

CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, imageRef); 
CGImageRelease(imageRef); 

Mon image est à l'envers, comment puis-je changer? Qu'est ce qui ne va pas avec mon code? Comment puis-je changer l'image devenue normale ?? THX .

+0

duplication possible de http://stackoverflow.com/questions/506622/cgcontextdrawimage-draws-image-upside-down-when-passed-uiimage-cgimage –

Répondre

2

Au lieu de cela:

CGContextDrawImage(UIGraphicsGetCurrentContext(), imageRect, imageRef); 

faire ceci:

[img drawInRect:CGRectMake(0, 0, 175, 175)] 

CGContextDrawImage ne conserve pas l'orientation.

Questions connexes