Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I scale a CGImage in an optimal way?

One ways to do is:

CGImageRef scaledImage(CGImageref, destination rect)
{
    context = CGBitmapContextCreate(rect...);
    CGContextDrawImage(context, rect);
    return CGBitmapContextCreateImage(context)
}

Questions:

Creating bitmap context can be quite expensive if image scale operation is very frequent. Is there any other way we can scale CGimage? Or caching such bitmap context for scaling operation is the only option?

like image 866
Bharat Ahuja Avatar asked Nov 09 '22 12:11

Bharat Ahuja


1 Answers

image scaling required full image processing, so you can speed up it using cached context (as you said before), or for example to scale image on GPU.

like image 98
Alexander Dalshov Avatar answered Nov 14 '22 23:11

Alexander Dalshov