Skip to content
New issue

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

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

Already on GitHub? # to your account

Support Heic format #444

Open
ffchung opened this issue Dec 12, 2023 · 1 comment
Open

Support Heic format #444

ffchung opened this issue Dec 12, 2023 · 1 comment

Comments

@ffchung
Copy link

ffchung commented Dec 12, 2023

Which SIST2 component is your Feature Request related to?

Scan

Is your feature request related to a problem? Please describe.

I have more Heic file. Heic format is becoming more popular among mobile users these days. I wish your app could support Heic format too. Thanks.

What would you like to see happen?

Suppot Heic.

Additional context

@ffchung
Copy link
Author

ffchung commented Dec 15, 2023

libheif : https://github.com/strukturag/libheif

Ref : https://github.com/strukturag/libheif/blob/master/examples/heif_convert.cc

`
#include <libheif/heif.h>

bool decodeheif(string filename)
{
heif_context* heif_ctx_ = heif_context_alloc();
if (!heif_ctx_) return false;

// read heif file
heif_error error = heif_context_read_from_file(heif_ctx_, filename.c_str), nullptr);
if (error.code != heif_error_Ok) return false;

// get handler
heif_image_handle *heit_handle_ = nullptr;
error = heif_context_get_primary_image_handle(heif_ctx_, &heif_handle_);
if (error.code != heif_error_Ok) return false;

// get width & height
width_ = heif_image_handle_get_width(heif_handle_);
height_ = heif_image_handle_get_height(heif_handle_);

// decode 
heif_image* heif_img_ = nullptr;
error = heif_decode_image(heif_handle_, &heif_img_, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, nullptr);
if (error.code != heif_error_Ok) return false; 

// get data
int stride;
const uint8_t *data = heif_image_get_plane_readonly(heif_img_, heif_channel_interleaved, &stride);
if(data == nullptr) return false;

}

// release
if (heif_ctx_) {
heif_context_free(heif_ctx_);
heif_ctx_ = nullptr;
}

if (heif_handle_) {
heif_image_handle_release(heif_handle_);
helf_hanale = nuliptr:

if (heif_img_) {
heif_image_release(heif_img_);
helf_1mg_ = nullptr;
}
`

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

No branches or pull requests

2 participants