Hi
I am doing image masking. First I was using C*GImageMaskCreate()* function for masking but now I am using your solution which you had posted for masking. My problem is it works fine on simulator but on device it is not transparent and it gives rectangle of mask image at background. The following is my code. Now tell me what I have to do?
Thanks.
CGContextRef mainViewContentContext;
CGColorSpaceRef colorSpace;
UIImage *orgImage=[UIImage imageNamed:@"orgimage.png"];
CGImageRef img = [orgImage CGImage];
colorSpace = CGColorSpaceCreateDeviceRGB();
mainViewContentContext = CGBitmapContextCreate (NULL, width, height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
CGColorSpaceRelease(colorSpace);
if (mainViewContentContext==NULL)
return NULL;
CGRect subImageRect;
CGImageRef tileImage;
subImageRect = CGRectMake(xCord,yCord,width,height);
tileImage = CGImageCreateWithImageInRect(img,subImageRect);
CGImageRef maskImage = mask_image.CGImage;
CGContextClipToMask(mainViewContentContext, CGRectMake(0, 0, width, height), maskImage);
CGContextDrawImage(mainViewContentContext, CGRectMake(0, 0, width, height), tileImage);
CGImageRef mainViewContentBitmapContext = CGBitmapContextCreateImage(mainViewContentContext);
CGContextRelease(mainViewContentContext);
UIImage *theImage = [UIImage imageWithCGImage:mainViewContentBitmapContext];
CGImageRelease(mainViewContentBitmapContext);