0

I try this -

    UIImage *flippedImage = [UIImage imageWithCGImage:clickedImage.CGImage 
scale:clickedImage.scale orientation:UIImageOrientationUpMirrored]; //give the mirror uiimage object

This method give me mirror image but when i save these image in an array the original(not mirror) image is saved.

even when i debug it, it shows the original image. But shows mirror if displayed.

I don't know what is the reason but, i think this method actually does not convert image in mirror form.

How do i get horizontally flipped/mirror image?

Sushobhit
  • 305
  • 4
  • 18
  • 1
    How do you save it in the array? Let's see that code. – Simon Degn Sep 10 '15 at 13:14
  • Do you update original `imageView` before saving like this: `clickedImage.image = flippedImage` – Kampai Sep 10 '15 at 13:31
  • possible duplicate of [How to flip UIImage horizontally?](http://stackoverflow.com/questions/5404706/how-to-flip-uiimage-horizontally) – Teja Nandamuri Sep 10 '15 at 13:36
  • have you looked at this answer : http://stackoverflow.com/questions/5404706/how-to-flip-uiimage-horizontally – Teja Nandamuri Sep 10 '15 at 13:37
  • No, It is not duplicate, because question here is flipped image not saved in array, array contains original one. The flipping part was done by OP, all other people also misguide from question. Read again fella. – Kampai Sep 10 '15 at 13:37
  • No, the question title clearly says ,how to get flipped image in iOS but not how to save the flipped image in array. – Teja Nandamuri Sep 10 '15 at 13:49
  • Maybe if OP change the title of his quesition , then it will not be a duplicate!!! – Teja Nandamuri Sep 10 '15 at 13:50
  • @Kampai i am saving the images in a array after get the flipped image using above code but when i use this array to print the images in GIF form it shows me the original images. that is my problem – Sushobhit Sep 10 '15 at 13:52
  • @Mr.T i update the title as you said but i have also doubt in my code as i said when i debug it show original image on flippedImage. but in device it print mirrored if directly used. – Sushobhit Sep 10 '15 at 14:10
  • please show us the code of how you are adding the image to array – Teja Nandamuri Sep 10 '15 at 14:16
  • UIImage *mFrameImg = [self getCurrentClickedImage]; if (mFrameImg){ [self.frameImgsArray addObject:mFrameImg]; } and in getCurrentClickedImage i use above code to return flipped image – Sushobhit Sep 10 '15 at 14:27

1 Answers1

0

Use this to get flipped image

   CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
        UIGraphicsBeginImageContext(rect.size);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextClipToMask(context, rect, image.CGImage);
        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

        return [UIImage imageWithCGImage:img.CGImage
                                   scale:1.0 orientation: UIImageOrientationLeftMirrored];
Rajesh
  • 10,318
  • 16
  • 44
  • 64
  • i get blank white image using this code. i want mirror image like as when we click using front camera of phone and phone show the mirror or flipped image. – Sushobhit Sep 10 '15 at 13:36