Re: Screenshot

Bj|rn Englund <[email protected]> Sun, 10 Aug 2003 23:38:16 +0200
Newsgroups gmane.comp.video.ogle.devel
Message-ID <[email protected]>
Thu Aug 07 2003, Martin Piskernig wrote:
> Hi!
> 
> I wanted to ask if it is possible to make the screenshot feature accessible 
> thru a DVD* call like DVDTakeScreenShot(DVDNav_t*,char* filename)?
> As it is now, I don't either have control about the filename nor can I emit a 
> "take screenshot" command from outside the output window. Well, it would 
> probably work with X key event simulate to send an 'i', but .... :-)
> It seems too difficult for me to write such a function because it would need 
> access to the graphics code, and I don't know if and how this is possible...
> 

Ok I did a fast implementation of 
DVDSaveScreenshot(DVDNav_t *, ScreenshotMode_t, char *formatstr)

mode can be ScreenshotModeWithSPU or WithoutSPU
formatstr can have %i to add an incrementing variable.
example: "/tmp/mypicture%02i.jpg" produces the files
"/tmp/mypicture00.jpg"
"/tmp/mypicture01.jpg"
"/tmp/mypicture02.jpg"
you just have to set the format the first time and then call it
with format = NULL (if you don't want to change it).
If no format or an illegal format is set ("%w" is illegal because w isn't
a conversion character, only 'i' is defined at the moment),
the format will default to "shot%04i.jpg".
%% may be used to get an '%' in the output filename.
%i, %3i, %03i -> nr, whitespace left padded nr, zero padded nr

The incrementing variable (%i) will be reset to zero when
a format other then NULL is set.
But if there already are files with that same format, the variable
will increment past them until an 'available' filename is created.
 
More conversion characters will come in the future, comments appreciated.

Please test.

(I also fixed the memory leak when saving screenshots, I hope)

/Björn