Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bpp(bits per pixel) to 32 bit for GIF #511

Merged
merged 6 commits into from
Jul 23, 2019

Conversation

zhongwuzw
Copy link
Contributor

For 8bpc and RGB color space, it's always 32bits per pixel. We can also use CGImageGetBytesPerRow(imageRef) * _height.

image

@bolsinga
Copy link
Contributor

bolsinga commented Jul 9, 2019

Please add a test.

@garrettmoon
Copy link
Collaborator

A test would definitely be good in this case. I wonder if the OS is working around our error in this case or we're getting lucky by using an unsupported but available format?

@zhongwuzw
Copy link
Contributor Author

Test added.

let pinCachedAnimatedImage = PINGIFAnimatedImage(animatedImageData: animatedData as Data)!
let bytesSize = UInt32((pinCachedAnimatedImage.image(at: 0, cacheProvider: nil)!.takeUnretainedValue() as CGImage).bytesPerRow) * pinCachedAnimatedImage.height

XCTAssert(pinCachedAnimatedImage.bytesPerFrame <= bytesSize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be == ? I think this test succeeds with the old bytesPerFrame

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a test! As @garrettmoon mentions, please ensure the test fails without the code change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, pinCachedAnimatedImage.bytesPerFrame should always <= bytesSize, because CGBitmapContextCreate may add padding and alignment when allocated memory, but in this sample url, seems we can use ==. Let's try it. :)

@ghost
Copy link

ghost commented Jul 11, 2019

🚫 CI failed with log

@garrettmoon
Copy link
Collaborator

You mind rebasing against master? I think I fixed a flakey test.

@zhongwuzw
Copy link
Contributor Author

@garrettmoon I triggered the CI, but seems all are pending. :)

Copy link
Collaborator

@garrettmoon garrettmoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

@garrettmoon garrettmoon merged commit d7ff599 into pinterest:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants