push output to mmapped file
J-Cake opened this issue · comments
Hi, I'm looking to draw an image into an mmap
ped 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
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
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.