Function open_image_from_bytes

Source
pub fn open_image_from_bytes(buffer: &[u8]) -> Result<PhotonImage, Error>
Expand description

Saves a image from a byte slice A PhotonImage is returned.

§Arguments

  • buffer - A byte slice containing the image you want to edit.

§Example

use photon_rs::native::open_image_from_bytes;

// Code to read a file to buffer. If you are reading from a file its better to use `open_image`
let buffer = std::fs::read("img.jpg").expect("File Should Open");

// Open the image. A PhotonImage is returned.
let img = open_image_from_bytes(buffer.as_slice()).expect("Buffer should be valid");

// ... image editing functionality here ...