Created
November 16, 2022 10:03
-
-
Save mebjas/649e0ce14eca81b130cc39213e6ed290 to your computer and use it in GitHub Desktop.
Code snippet for reading image using fd and decoding with our image decoder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read the image | |
std::unique_ptr<Image> image = nullptr; | |
{ | |
std::string image_buffer; | |
image_buffer.resize(fd_length); | |
int remaining_length = read(fd, &image_buffer[0], length); | |
if (remaining_length != 0) { | |
return env->NewStringUTF("Failed to read full image"); | |
} | |
image = ImageFactory::FromString(image_buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment