Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Native support for resizing images while decoding #69

Closed
sahilbajaj opened this issue Dec 22, 2021 · 6 comments
Closed

Native support for resizing images while decoding #69

sahilbajaj opened this issue Dec 22, 2021 · 6 comments

Comments

@sahilbajaj
Copy link

Currently the images are decoded at their original resolution.

Even though BitmapExt provides bitmap resizing capabilities, sometimes it doesn't make sense to decode images at original resolution first especially when they're large.

@soywiz
Copy link
Collaborator

soywiz commented Dec 22, 2021

@sahilbajaj do you know any API that is providing this functionality already, as a source of inspiration?

@sahilbajaj
Copy link
Author

yeah.. on Android there is a very widely used something called BitmapFactory.Options

and we can pass BitmapFactory.decode(path, Options)

@soywiz
Copy link
Collaborator

soywiz commented Dec 22, 2021

Oh, nice. Thanks for sharing.

I think we could do something similar and allow to provide a width and height to the decoding options.

We have formats provided by korim/user and native decoders.

I guess we should consider a mechanism that support for example emitting rows and executing code for each emitted row in a generic way to do the scaling (but still in some cases like jpeg progressive mode, support the decoder to do it another way), and then also support providing those parameters for example for Android or other native providers supporting scaling at the native decoder layer.

What is your usecase here? Making thumbnails for potentially very large images using as few memory as possible?

@sahilbajaj
Copy link
Author

sahilbajaj commented Dec 22, 2021

We are building a video editor using korlibs. (primarily korge) 😜
And the images chosen from the users' gallery could be of any size (4ks are normal these days).
And since displays are usually around 1080p and memory is always constrained, we want to be very cautious.

@sahilbajaj
Copy link
Author

sahilbajaj commented Dec 22, 2021

Yeah.. That's the thing. We'll have to implement our custom down sampler as well besides using the native platform ones.

@srinivas-codezyng
Copy link

iOS does have support for downsampling in CoreGraphics framework. There is an api called CGImageSourceCreateThumbnailAtIndex which handles the downsampling based on the downsample options that we pass as a parameter. Here is good WWDC video about the usage of this API(starting at 11 minutes) : https://developer.apple.com/videos/play/wwdc2018/219/

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

No branches or pull requests

3 participants