Skip to content

Instantly share code, notes, and snippets.

@mebjas
Created November 16, 2022 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mebjas/649e0ce14eca81b130cc39213e6ed290 to your computer and use it in GitHub Desktop.
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.
// 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