AP.
AP.

Reputation: 5323

difference between CGContextDrawImage et UIImage drawInRect

I was wondering which method is the best when there is a need to scale images? Do you have benchmarks on this?

Thanks in advance.

Regards,

Upvotes: 2

Views: 2762

Answers (1)

kennytm
kennytm

Reputation: 523494

Internally, -drawInRect: will rotate the image into the correct orientation according to the imageOrientation property, then flip the image upside down to convert UIKit coordinates into CoreGraphics coordinates.

Then it will call CGContextDrawImage.

In this sense, -drawInRect: is surely slower. But using CGContextDrawImage to target UIKit requires one to do the transformation hassles which may not worth for maintenance.

Upvotes: 12

Related Questions