I've and UIImage with transparency.
I'm uploading the PNG representation of the UIImage to my web service, which accepts data which is less than let say 800K.
So basically I would like to reduce the size (NOT THE GEOMETRICAL BUT PHYSICAL I.E. in bytes) i.e. to reduce the quality of the uimage.
PLEASE DON'T POINT ME TO Quartz Guideline
PLEASE DON'T OFFER TO use JPEG representation of UIImage IT DOESNT SUPPORT TRANSPARENCY
PLEASE DON'T OFFER TO MAKE AN IMAGE SMALLER THEN TO SCALE IT
I need to reduce the colors in UIImage any ideas how to achieve it by means of Quartz ?
Following I've tried, created a context and drawn image on. Have played with bytesPerRow but still failing, please help to find the solution !
size_t width = CGImageGetWidth(image.CGImage);
size_t height = CGImageGetHeight(image.CGImage);
size_t bitsPerComponent = CGImageGetBitsPerComponent(image.CGImage);
size_t bytesPerRow = CGImageGetBytesPerRow(image.CGImage);
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);
CGContextRef ctx = CGBitmapContextCreate(NULL, // Let CG allocate it for us
width,
height,
bitsPerComponent,
bytesPerRow,
colorSpace,
kCGImageAlphaPremultipliedLast); // RGBA
CGColorSpaceRelease(colorSpace);
CGRect rect = CGRectMake( 0, 0, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage));
CGContextDrawImage( ctx, rect, image.CGImage);
CGImageRef newImg = CGBitmapContextCreateImage(ctx);
UIImage* compressedImage = [UIImage imageWithCGImage:newImg];
CGImageRelease(newImg);
CGContextRelease(ctx);