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

Bit image from bytes #9

Merged
merged 2 commits into from Feb 26, 2024

Conversation

ldicocco
Copy link
Contributor

In some applications an image is not retrieved from a file, but from something like rust_embed or base64, so a possibility to print an image from bytes is useful.

@fabienbellanger fabienbellanger merged commit ae3e82d into fabienbellanger:main Feb 26, 2024
1 check passed
fabienbellanger pushed a commit that referenced this pull request Feb 26, 2024
@fabienbellanger
Copy link
Owner

@ldicocco could you add a test for bit_image_from_bytes method in protocol.rs please?

@fabienbellanger
Copy link
Owner

I try this:

#[cfg(feature = "graphics")]
#[test]
fn test_bit_image_from_bytes() {
    let protocol = Protocol::new(Encoder::default());
    let img = image::open("./resources/images/small.jpg").unwrap();

    assert_eq!(
        protocol
            .bit_image_from_bytes(
                img.as_bytes(),
                BitImageOption::new(None, None, BitImageSize::default()).unwrap(),
            )
            .unwrap(),
        vec![
            29, 118, 48, 0, 2, 0, 16, 0, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 255, 255, 255,
            255, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128
        ]
    );
}

But I have this error Result::unwrap() on an Err value: Io("The image format could not be determined")`.

Would you have an example?

@ldicocco
Copy link
Contributor Author

ldicocco commented Feb 26, 2024 via email

@ldicocco ldicocco deleted the bit_image-from-bytes branch February 26, 2024 14:40
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

Successfully merging this pull request may close these issues.

None yet

2 participants