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

"invalid bounding box" #17

Open
weiying-chen opened this issue Apr 21, 2023 · 0 comments
Open

"invalid bounding box" #17

weiying-chen opened this issue Apr 21, 2023 · 0 comments

Comments

@weiying-chen
Copy link

weiying-chen commented Apr 21, 2023

Why is the following code producing "invalid bounding box"?

use ril::prelude::*;

fn main() -> ril::Result<()> {
    let mut image = Image::<Rgba>::open("sample.png")?;
    let (width, height) = image.dimensions();

    let vertices = vec![(50, 0), (100, 25), (100, 75), (50, 100), (0, 75), (0, 25)];

    let border = Border::<L>::new(L(255), 1);
    let hexagon = Polygon::from_vertices(vertices)
        .with_fill(L(255))
        .with_border(border);

    let mut mask = Image::new(width, height, L(0));

    mask.draw(&hexagon);
    image.mask_alpha(&mask);
    image.save_inferred("sample_hexagon.png")?;
    Ok(())
}

This error doesn't happen if you remove .with_border(border);.

By the way, this is sample.png: https://i.stack.imgur.com/hTIji.jpg. It's a png image of 1024 x 1024 pixels.

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

1 participant