Skip to content

How lazy-decoding mechanism works #3615

Answered by dreampiggy
hp1909 asked this question in Q&A
Discussion options

You must be logged in to vote

Apple's ImageIO and UIKit use lazy decoding.

CGImage is lazy, not a data which hold memory buffer. It query the pixel buffer using callback (not like Android Bitmap or other things you familiar)

A CGImage can be created with CGDataProvider, which can provide the callback to access underlying pixel buffer (a 2-dimension array). So this not means the data must be always in memory (surprise ?)

See: https://developer.apple.com/documentation/coregraphics/cgdataprovidergetbytescallback?language=objc

So, ask yourself:

If CGImage is lazy, when UI render on screen (this happended on main queue), will this effect frame rate ?

For JPEG and PNG, the lazy cause the decoding happened on main queue, b…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@hp1909
Comment options

Answer selected by hp1909
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants