开发者

mirror image+iphone

I want a functionality in my iPhone application which will convert the image to its mirror like way.

Like if there is an image of man with his left hand up Then the converted image must have the same man with his right hand up.

Any code or link will be really appreciated

开发者_运维技巧Thanks in advance for any help.


You might try this

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

Sorry I can't be more help. It was a while ago that I used this horizontally flip a UIView, so I am bit rusty on specifics.


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



// 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜