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

push output to mmapped file #471

Open
J-Cake opened this issue Jul 22, 2021 · 2 comments
Open

push output to mmapped file #471

J-Cake opened this issue Jul 22, 2021 · 2 comments

Comments

@J-Cake
Copy link

J-Cake commented Jul 22, 2021

Hi, I'm looking to draw an image into an mmapped file, I'm not entirely sure where to go.

let mut canvas = Canvas::new(Vector2F::new(dimensions.0 as f32, dimensions.1 as f32));
let mut ctx = canvas.get_context_2d(CanvasFontContext::from_system_source());
ctx.set_fill_style(ColorU::black());

Is this too vague or can someone explain how I'd go about this?
Thanks in advance

@pshaughn
Copy link

I don't think it's possible to do this directly, at least not portably. The framebuffer being written into is up to the GPU renderer to manage, and I don't think there's a well-defined way to make the GPU and file mmap both use the same RAM. Also, you would end up with a series of pixel color values with no width/height information, not an image file in a readable image format.

The most relevant example code I can find is here, but it only writes to a regular file (using image's functionality of choosing file format by file extension): https://github.com/servo/pathfinder/blob/master/demo/common/src/renderer.rs#L271-L289

@J-Cake
Copy link
Author

J-Cake commented Jul 24, 2021

I don't need to worry about width and height, as I'm pulling that information from elsewhere, In fact, I'm actually looking for a byte-wise solution, so an uncompressed bitmap image.

What you pointed out is almost exactly what I'm looking for, anyway, except that (I'm assuming here) it's compressed.

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