Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Created November 17, 2019 21:41
Show Gist options
  • Save dmytro-anokhin/4320b82b71dd8db6f2afe9452e4f9275 to your computer and use it in GitHub Desktop.
Save dmytro-anokhin/4320b82b71dd8db6f2afe9452e4f9275 to your computer and use it in GitHub Desktop.
func isFrameComplete(at index: Int) -> Bool {
assert(frameCount > index)
// CGImageSourceGetStatusAtIndex() changes the return status value from kCGImageStatusIncomplete
// to kCGImageStatusComplete only if (index > 1 && index < frameCount() - 1). To get an accurate
// result for the last frame (or the single frame of the static image) use CGImageSourceGetStatus()
// instead for this frame.
if index == frameCount - 1 {
return CGImageSourceGetStatus(imageSource) == .statusComplete
}
return CGImageSourceGetStatusAtIndex(imageSource, index) == .statusComplete
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment