views:

117

answers:

2

What's the most efficient way to create a thumbnail from an arbitrary web image in iPhone?

+1  A: 

This is best way that I've found.

TechZen
Gave me "CGBitmapContextCreate: unsupported colorspace." on first try. After checking the comments it seems that the scope of that library is very limited. I can't assume much of the images (other than they are PNG or JPEG).
hgpc
That is caused by the API being very fussy about the relationship between the bit resolution, the alpha and the colorspace. You have to check that the image has the correct configuration and then create a new, properly formatted image if it does not. That is really unavoidable. I don't think anyone has done a generic resize that works with everything.
TechZen
How do I check if it has the right configuration and then create a properly formatted image if it does not?
hgpc
A: 

The only way that I've found so far that works on any images is to show it in an ImageView with the right size, and then create a bitmap from that view.

Far from efficient, though.

hgpc