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

Better way for decoding image #508

Open
hovox opened this issue Jun 24, 2019 · 2 comments
Open

Better way for decoding image #508

hovox opened this issue Jun 24, 2019 · 2 comments

Comments

@hovox
Copy link
Contributor

hovox commented Jun 24, 2019

I'm looking into pin_decodedImageWithData method and wandering can't we find better way for decoding ? With current implementation in order to decode an image we are creating additional bitmap with the same size and draw on it. We could draw into 1x1 context like done here , concrete implementations are here. If there may be issues with image orientation(in which I'm not sure) we can do this way only when image is in portrait mode. By doing this way we can save temporary memory of image size.

@hovox
Copy link
Contributor Author

hovox commented Jun 26, 2019

We can set CGContextSetInterpolationQuality to kCGInterpolationNone it should be more performant than default one. Here is the documentation link.

@hovox
Copy link
Contributor Author

hovox commented Jul 11, 2019

There are cases where suggested solution(drawing on 1x1 canvas) will not work correctly. Specifically if we get HEIC encoded image which alpha is not premultiplied we will get wrong decoded image because when compositing layers iOS considers that alpha should be premultiplied. So I think current solution works right, we still can disable interpolation to have better drawing speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants