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

Can't resume drawing after calling BitmapTarget::copy_raw_pixels. #568

Closed
doinkythederp opened this issue Apr 16, 2024 · 0 comments · Fixed by #569
Closed

Can't resume drawing after calling BitmapTarget::copy_raw_pixels. #568

doinkythederp opened this issue Apr 16, 2024 · 0 comments · Fixed by #569

Comments

@doinkythederp
Copy link
Contributor

On Windows specifically, it's not possible to make further draws to a BitmapTarget after calling BitmapTarget::copy_raw_pixels. I believe this is because self.context.end_draw()?; is called during aforementioned method, without a corresponding begin_draw() call. It fails with an error code of BackendError(hresult 88990001).

Example:

use piet::{kurbo::Rect, Color, ImageFormat};
use piet_common::{Device, RenderContext};

fn main() {
    let mut piet = Device::new().unwrap();
    let mut bitmap = piet.bitmap_target(256, 256, 1.0).unwrap();
    {
        let mut rc = bitmap.render_context();
        let rect = Rect::new(10.0, 10.0, 100.0, 100.0);
        rc.fill(rect, &Color::RED);
        rc.finish().unwrap();
    }
    let mut data = vec![0; 256 * 256 * 4];
    bitmap
        .copy_raw_pixels(ImageFormat::RgbaPremul, &mut data)
        .unwrap();

    {
        let mut rc = bitmap.render_context();
        let rect = Rect::new(50.0, 50.0, 150.0, 150.0);
        rc.fill(rect, &Color::GREEN); // ERROR!
        rc.finish().unwrap();
    }
}
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 a pull request may close this issue.

1 participant