Post subject: What is the codec/format of comm.socketServerScreenShot()?
Joined: 8/9/2021
Posts: 1
When I send a screenshot via comm.socketServerScreenShot() to my socket (Python) I receive a byte-string, but I have no clue how it is encoded. How can I convert the byte-string in a RGB-like format? (Code is not neccesary, just what FORMAT it uses!) Thanks in advance
Zinfidel
He/Him
Player (206)
Joined: 11/21/2019
Posts: 247
Location: Washington
I don't have an answer for you unfortunately, but I do have bread crumbs that you can follow that might get you somewhere. The tl;dr is that it's some sort of GDI+ raw format. If you can't figure out the format, maybe you can call .net methods inside of python to deserialize that way? Or even call native gdi+ functions. The memory stream is in the format of a serialized .NET System.Drawing.Bitmap. This conversion is done here in BizHawk: https://github.com/TASVideos/BizHawk/blob/master/src/BizHawk.Client.EmuHawk/MainForm.cs#L606 .NET serializes the image this way: https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/ImageConverter.cs,117 The read function is right above it ultimately leads to functions that use GDI+: https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Image.cs,249 I know this isn't what you asked for but it's what I figured out in 10 minutes and as far as I feel like going. Good luck!
YoshiRulz
Any
Editor, Emulator Coder
Joined: 8/30/2020
Posts: 106
Location: Sydney, Australia
Source code link rotted, here's a permalink. It uses .NET's default format which seems to be PNG, 8bpc sRGB. Remember that from 2.9 (dev builds from c49a8d338), the payload is prefixed with the length using the same format as socketServerSend.
I contribute to BizHawk as Linux/cross-platform lead, testing and automation lead, and UI designer. This year, I'm experimenting with streaming BizHawk development on Twitch. nope Links to find me elsewhere and to some of my side projects are on my personal site. I will respond on Discord faster than to PMs on this site.
Hey look buddy, I'm an engineer. That means I solve problems. Not problems like "What is software," because that would fall within the purview of your conundrums of philosophy. I solve practical problems. For instance, how am I gonna stop some high-wattage thread-ripping monster of a CPU dead in its tracks? The answer: use code. And if that don't work? Use more code.