mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-04-30 02:22:55 +00:00
HLE: CaptureManager: SaveScreenShot: properly handle screenshot image data (#18)
no way this was working before, and if it did, just pure luck, unsafe blind copy of bytes as is and zero checks. i only tested tomodachi, but should fix all games that were crashing on saving screenshots the crash was happening because the screenshot buffer was bigger than the bitmap buffer, so marshall.copy() was raising an unhandhled expection crashing the emu. on top of this, because the data was just copied as is, the result image was garbled. [fixes #304](https://github.com/Ryubing/Issues/issues/304) Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/18
This commit is contained in:
@@ -118,8 +118,11 @@ namespace Ryujinx.HLE.HOS.Services.Caps
|
||||
}
|
||||
|
||||
// NOTE: The saved JPEG file doesn't have the limitation in the extra EXIF data.
|
||||
using SKBitmap bitmap = new(new SKImageInfo(1280, 720, SKColorType.Rgba8888));
|
||||
Marshal.Copy(screenshotData, 0, bitmap.GetPixels(), screenshotData.Length);
|
||||
using SKBitmap bitmap = new(new SKImageInfo(1280, 720, SKColorType.Rgba8888, SKAlphaType.Premul));
|
||||
int dataLen = screenshotData.Length > bitmap.ByteCount ? bitmap.ByteCount : screenshotData.Length;
|
||||
|
||||
Marshal.Copy(screenshotData, 0, bitmap.GetPixels(), dataLen);
|
||||
|
||||
using SKData data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80);
|
||||
using FileStream file = File.OpenWrite(filePath);
|
||||
data.SaveTo(file);
|
||||
|
||||
Reference in New Issue
Block a user