Mirror Image + iphone

I need functionality in an iPhone app that converts an image to a mirror.

As if there is an image of a person with his left hand up, then the inverted image should have the same person with his right hand.

Any code or link will be truly appreciated.

Thanks in advance for your help.

+3
source share
3 answers

You can try this

myImageView.transform = CGAffineTransformMake(-1,0,0,1,0,0);

Sorry, I can’t help anymore. Some time ago, I used this horizontally, flipping UIView, so I'm a bit rusty in specifics.

+3
source
myView.transform = CGAffineTransformMake(-1,0,0,-1,0,0);
+1
source

// convert CIImage to unsigned char*
NSBitmapImageRep * bitRep = [[NSBitmapImageRep alloc] initWithCIImage:sourceImage];
unsigned char * pixels = (unsigned char *)[bitRep bitmapData];

// find mirrored pixel, for 1D pixels array
// for 2D array it will be something like:
// pixels2D[x,y] = pixels2D[Image.width-1-x,y]

// convert modified unsigned char* back to CIImage
CGColorSpaceRef colorSpaceToUse = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
NSData *_pixelsData = [NSData dataWithBytesNoCopy:pixels length:(sizeof(unsigned char)*4*Image.Width*Image.Height) freeWhenDone:YES ];
CIImage *_dataCIImage = [[[CIImage alloc] initWithBitmapData:_pixelsData bytesPerRow:(Image.Width*4*sizeof(unsigned char)) size:CGSizeMake(Image.Width,Image.Height) format:kCIFormatARGB8 colorSpace:colorSpaceToUse] autorelease];
0

Source: https://habr.com/ru/post/1771919/


All Articles