Open daisy1754 opened 10 years ago
I made another commit to answer discussion above. Please have a look :smile:
Hi, I tried to replace "blackColor" by "clearColor". This doesn't change anything. Someone could give me a hint about how I can get a clear background? Thanks in advance
Edit: I found the answer. My source hadn't any alpha chanel. => Solution to add alpha canal to add in -(CGIImageRef)newTransformedImage method
//ADD ALPHA CHANEL { CGImageAlphaInfo alpha = CGImageGetAlphaInfo(source); BOOL hasAlpha = (alpha == kCGImageAlphaFirst || alpha == kCGImageAlphaLast || alpha == kCGImageAlphaPremultipliedFirst || alpha == kCGImageAlphaPremultipliedLast);
if (!hasAlpha) {
size_t width = CGImageGetWidth(source);
size_t height = CGImageGetHeight(source);
CGContextRef offscreenContext = CGBitmapContextCreate(NULL,
width,
height,
CGImageGetBitsPerComponent(source),
0,
CGImageGetColorSpace(source),
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(offscreenContext, CGRectMake(0, 0, width, height), source);
source = CGBitmapContextCreateImage(offscreenContext);
CGContextRelease(offscreenContext);
}
//ADD ALPHA CHANEL
Currently, if users scale an image smaller than bounds area, a padding area is filled with black color. This PR change the behaviour to filling padding with a color of the background view. The result should be more WYSIWYG for users.