Fix save to image on Windows (#32914)

* Read pixels in same format (gl::RGBA) as the texture

Signed-off-by: crbrz <cristianb@gmail.com>

* Add read pixels test

Signed-off-by: crbrz <cristianb@gmail.com>

* Use patched surfman

Signed-off-by: crbrz <cristianb@gmail.com>

* Update surfman to 0.9.5

Signed-off-by: crbrz <cristianb@gmail.com>

---------

Signed-off-by: crbrz <cristianb@gmail.com>
This commit is contained in:
Cristian Brinza 2024-08-03 23:04:26 +03:00 committed by GitHub
parent bb176514c6
commit 7c2c383bb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 114 additions and 11 deletions

View file

@ -2246,7 +2246,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
Some(Image {
width: img.width(),
height: img.height(),
format: PixelFormat::RGB8,
format: PixelFormat::RGBA8,
bytes: ipc::IpcSharedMemory::from_bytes(&img),
id: None,
cors_status: CorsStatus::Safe,
@ -2269,7 +2269,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
FramebufferUintLength::new(width),
FramebufferUintLength::new(height),
);
let dynamic_image = DynamicImage::ImageRgb8(img);
let dynamic_image = DynamicImage::ImageRgba8(img);
if let Err(e) = dynamic_image.write_to(&mut file, ImageFormat::Png) {
error!("Failed to save {} ({}).", path, e);
}