Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Pixel Byte vs Bytes #149

Open
HarrisDePerceptron opened this issue Feb 14, 2023 · 1 comment
Open

Pixel Byte vs Bytes #149

HarrisDePerceptron opened this issue Feb 14, 2023 · 1 comment

Comments

@HarrisDePerceptron
Copy link

HarrisDePerceptron commented Feb 14, 2023

why are these not equal

assert_eq!(img.get_raw_pixels().len(),  img.get_bytes().len())

@igrep @rsk700 @Horki @Clivern @samuelvanderwaal

@nathanbabcock
Copy link
Contributor

@HarrisDePerceptron

    /// Convert the PhotonImage to raw bytes. Returns JPEG.
    pub fn get_bytes(&self) -> Vec<u8> {
        let mut img = helpers::dyn_image_from_raw(self);
        img = ImageRgba8(img.to_rgba8());
        let mut buffer = vec![];
        img.write_to(&mut buffer, image::ImageOutputFormat::Png)
            .unwrap();
        buffer
    }

As the doc comment says, get_bytes is meant to be an encoded image, which is different. Although it seems it returns a PNG, not JPEG.

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

No branches or pull requests

2 participants