Without knowing your project specifics, I’m willing to guess that it’s not screen capture that’s slow, but rather writing a large PNG file - you can test this by loading the file back as a sprite, drawing it on a surface, and calling surface_save
.
GML has a buffer_compress
function that you can use to make your own PNG encoder, but it does not expose the underlying zlib functions for compressing a portion of data at the time, so whatever you make won’t be any better than existing surface_save
- has to be a native extension doing either this or saving on a separate thread in general.
Or maybe you can write 32-bit BMP files instead - these have a basic header followed by RGBA bytes that are stored upside-down (bottom row first).