synap5e / obs-screenshot-plugin

An OBS Studio filter plugin to save screenshots of a source/scene
GNU General Public License v2.0
136 stars 20 forks source link

Saving as raw generates image larger than source #10

Closed GXTX closed 4 years ago

GXTX commented 4 years ago

I don't really have a need for raw images but I ran into an issue trying to save one. The resolution of the source and canvas is 720x480 but saving the raw image it will only properly display when you set the resolution in your editing program as 736x480.

I've attached a copy of both raw and png format. images.zip

I might be mistaken but I believe this was also an issue with regular image saving in a previous version? RE: #6 ?

synap5e commented 4 years ago

This is an artifact of all linesizes being 32-byte aligned in OBS. The format I describe is

The header comprises of 4 uint32_t's in the format width, height, linesize, index. The header is then followed by height * linesize bytes of image data

so I'm going to call this a feature not a bug 😜

I suppose it is unintuitive to do this way, and I could simply have reformatted the image to width=linesize then only emitted 3 words (width, height, index) in the header followed by width*height bytes, but at the time I chose not to (I suppose this way is more "raw" to what is going on in OBS and "faster" although at 4Hz the difference is not worth considering). Because of this I'm going to stick with the legacy behavior, although I could make a note of this caveat it in the readme.