开发者

Does it matter what color format an image has when saving it as PNG?

I am creating tiles for a larger image and I'm saving them to disk. Question: Is there any way I can optimize the image so that reading and decompressing the PNG from disk is faster? Possibly by changing the order or color bytes in the color space on a custom bitmap context from which the image is saved?

UIImage *fullSizeImage = [self cachedImageWithURL:imageURL];
CGRect tileRect = (CGRect){{column*tileSize.width, row*tileSize.height}, {tileSize.width, tileSize.height}};
CGRect totalRect = (CGRect){CGPointZero, fullSizeImage.size};
tileRect = CGRectIntersection(tileRect, totalRect);
CGImageRef tileImage = CGImageCreateWithImageInRect([fullSizeImage CGImage], tileRect);
UIImage *开发者_运维百科retImage = [UIImage imageWithCGImage:tileImage];
[self.cache setObject:retImage forKey:cacheURL cost:0];
[retImage savePNGAsyncToURL:cacheURL];


I've benchmarked this, and it looks that speed is closely correlated to file size (smaller file is faster):

http://imageoptim.com/tweetbot.html

If you're OK with lossy compression, then use pngquant to create those files. At 8bpp they'll have 1/4th of data to begin with.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜