CGImageRef _backgroundImageViewRef = _backgroundImageViewInTweek.image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef contextRef = CGBitmapContextCreate(NULL, _backgroundImageViewInTweek.image.size.width, _backgroundImageViewInTweek.image.size.height,
8, _backgroundImageViewInTweek.image.size.width * 4,
colorSpace, kCGImageAlphaPremultipliedLast|kCGBitmapByteOrderDefault);
CGContextDrawImage(contextRef, CGRectMake(0, 0, _backgroundImageViewInTweek.image.size.width, _backgroundImageViewInTweek.image.size.height), _backgroundImageViewRef);
CGContextSetLineWidth(contextRef, 4);
CGContextSetRGBStrokeColor(contextRef, 0.0, 0.0, 1.0, 0.5);
CGRect costume_rect = CGContextConvertRectToDeviceSpace(contextRef, CGRectMake(0.0f,0.0f,171, 217));
CGContextDrawImage(contextRef, costume_rect, _costumeImageViewInTweek.image.CGImage);
UIImage *_mergingBackgroundAndCostumeImage;
_mergingBackgroundAndCostumeImage =[UIImage imageWithCGImage:CGBitmapContextCreateImage(contextRef)];
CGContextRelease(contextRef);
CGColorSpaceRelease(colorSpace);
With Regards,
Dinesh Sharma