Community

SCI Programming => SCI Development Tools => Topic started by: MusicallyInspired on October 10, 2020, 11:17:56 PM

Title: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 10, 2020, 11:17:56 PM
Is there a command line tool or something anywhere that will take SCI0 Picture resources and export each draw command step in frames? I'm trying to basically make an animated GIF of a Picture resource drawing from beginning to end. Is there any easy way to do this besides copying and pasting each frame from the Pic editor or capturing SCI Decoder drawing Pictures from DOSBox?
Title: Re: Batch export vector draw commands one by one
Post by: troflip on October 11, 2020, 01:27:16 PM
There's no way to animate the steps, no. That would be neat though.

You can just use a gif capture tool (like GifCam) and either manually move the pic slider, or put focus at the top of the piccommand cmd window and arrow down.
Title: Re: Batch export vector draw commands one by one
Post by: ZvikaZ on October 11, 2020, 02:07:58 PM
Maybe it's possible to achieve such animation by running Dosbox/ScummVM in (very) slow motion?
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 11, 2020, 03:39:56 PM
I used SCI Decoder (old DOS resource viewing tool) and captured that in DOSBox but it uses that ZMBV codec and when you convert it so much quality is lost. Not to mention you can't resize it. Then transforming video into a GIF loses even more data. I ended up just capturing the Pic editor and manually moving through the steps with Nvidia Desktop Capture and cropping the video afterward. No way to make a good GIF it seems other than cooying and pasting every single drawing frame.
Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 11, 2020, 03:45:18 PM
There's no way to animate the steps, no. That would be neat though.

You can just use a gif capture tool (like GifCam) and either manually move the pic slider, or put focus at the top of the piccommand cmd window and arrow down.
That's literally what I did five years ago.

(http://helmet.kafuka.org/logopending/wp-content/uploads/2018/12/tumblr_nrn7jpZstN1r1hfpzo2_400.gif)
Title: Re: Batch export vector draw commands one by one
Post by: Charles on October 11, 2020, 11:09:21 PM
That sounds incredibly tedious. Maybe a hundred or more drawing “frames” and cropping et al.

If you’re doing a bunch of them, wouldn’t it be relatively easy to hack something into SCICompanion to auto increment the playback slider and save a BMP at each step?

You could even get fancy and skip BMP output on commands that don’t draw anything (like enable/disable control/visual, or palette changes). Then you’d have a series of BMP files you could drop into some other 3rd party program to create the gif.
Title: Re: Batch export vector draw commands one by one
Post by: cosmicr on October 12, 2020, 01:57:01 AM
It's not really difficult to do, it just takes time to implement.

I've got my own SCI Picture viewer which I wrote - I'll have a look and see if I can make it output each command to an image.

Should be able to have it by tomorrow (anyone feel free to get it done sooner!)
Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 12, 2020, 05:55:32 AM
Seriously? Just zoom out to 1:1, put the targeting window for GifCam roughly around the edge of the picture frame, hit record, and hold down in the command list. Bam.

Cropping in GifCam is a bit of a chore but if you have anything else like... I dunno, Aseprite? You can just use that to crop away the blue border.
Title: Re: Batch export vector draw commands one by one
Post by: troflip on October 12, 2020, 05:29:54 PM
That sounds incredibly tedious. Maybe a hundred or more drawing “frames” and cropping et al.

I've done this many times before for making twitter gifs, I don't find it hard at all. It takes about as long as it takes to hold down the down arrow key in the cmd window, or slide the horizontal slider across the screen. Then bam, save gif and you're done.

Not sure what cropping you'd need to do. Just position gifcam over the portion of the pic window that has the pic?

Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 13, 2020, 08:00:04 AM
Not sure what cropping you'd need to do. Just position gifcam over the portion of the pic window that has the pic?
I've found this to be a bit iffier to do than you make it sound, tbh, if you want only the picture and none of the blue border.

Oh god why'd I just think the words "pic menu, export to gif"?
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 13, 2020, 03:50:39 PM
That's what I was thinking.  ;D It already does this for View resource Loop Cels. Obviously the graphic types are quite different...
Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 13, 2020, 05:52:39 PM
Obviously. But if it can render a picture at any point in the command list, and export it to a bitmap, and the animated GIF thing is right there...
Title: Re: Batch export vector draw commands one by one
Post by: lskovlun on October 14, 2020, 05:29:06 AM
I would try asking this guy (https://twitter.com/32bitkid).
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 14, 2020, 08:39:13 AM
Is that the same guy who runs the Pixel Art Of Sierra Twitter account? (Or perhaps this guy just used PAOS's GIF post?) It looks like the same types of animations. If it is, I already asked him and he said he's using an internal tool that is currently too convoluted and he's not comfortable with releasing it publicly.
Title: Re: Batch export vector draw commands one by one
Post by: troflip on October 14, 2020, 03:22:54 PM
Real support for this would include sub-command frames. For instance a large fill operation could take up several frames. So it draws slowly just like AGI did on computers back in the day. (Or was that just on the Apple II?)
Title: Re: Batch export vector draw commands one by one
Post by: Collector on October 14, 2020, 07:55:42 PM
It was early AGI in general. I have a booter image that draws that slowly if I drop the DOSBox cycles low enough.
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 14, 2020, 08:08:03 PM
I don't think that would be necessary. I'd be content with such a feature that just *bam* painted the floodfill without any extra frames of animation.
Title: Re: Batch export vector draw commands one by one
Post by: cosmicr on October 14, 2020, 10:10:09 PM
Okay, here it is attached.

It's a windows executable. I wrote it in Linux, but I'm hopeless at portable stuff(I don't get libraries), so hopefully it works.

It's got a heap of debugging text which you can ignore but basically run it as:

Code: [Select]
scipictureviewer.exe pic.000
It will churn away for a minute or so, saving all the frames to the current directory.

Here is an example of output. Like others have said, it would look better if it had all the parts of each command, but still cool. Also these files are huge (for animated gifs).
(https://i.imgur.com/lICzkfo.gif)

This was a fun little exercise.  I wrote this viewer as a way to understand how picture resources work, it's not perfect, I have some bugs with patterns, filling, and control/priority screens at the moment, but it's good enough for this. Disclaimer: anything that goes wrong is not my problem!

And for what it's worth - it IS just as easy to use GifCam on Sci Companion, I only made this for fun and education.
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 14, 2020, 11:21:07 PM
This is super cool thanks for sharing!! Works great on Windows except it just hangs after it's finished and doesn't seem to do anything. Pressing CTRL+C drops back to prompt easily enough, though.

I notice it does get some pen tool pixel drawing wrong but that's expected as you said there are some bugs. I just made the final frame a capture of the proper final image and nobody's the wiser.
Title: Re: Batch export vector draw commands one by one
Post by: cosmicr on October 15, 2020, 12:03:46 AM
Awesome glad I could help!

Not sure why it hangs - it's supposed to open a window with the finished image. Did it report 0xFF end of picture at the end?

Meh, like I said, cross-platform programming isn't my forte - I was coding in linux, but linux executable distribution is hard, so I ported it to windows, but god knows what issues that could have introduced.

That Zelda title screen looks awesome. Looking forward to seeing more animated gifs!
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 15, 2020, 01:06:11 AM
Ah I just ran it again and a new window DID pop up showing the final image. Before it just said END OF PICTURE. Though, maybe I didn't just didn't notice the new window popup the first time for whatever reason. So it works as expected after all.
Title: Re: Batch export vector draw commands one by one
Post by: ZvikaZ on October 15, 2020, 03:27:58 AM
Okay, here it is attached.

It's a windows executable. I wrote it in Linux, but I'm hopeless at portable stuff(I don't get libraries), so hopefully it works.

It's got a heap of debugging text which you can ignore but basically run it as:

Code: [Select]
scipictureviewer.exe pic.000
It will churn away for a minute or so, saving all the frames to the current directory.

Here is an example of output. Like others have said, it would look better if it had all the parts of each command, but still cool. Also these files are huge (for animated gifs).
(https://i.imgur.com/lICzkfo.gif)

This was a fun little exercise.  I wrote this viewer as a way to understand how picture resources work, it's not perfect, I have some bugs with patterns, filling, and control/priority screens at the moment, but it's good enough for this. Disclaimer: anything that goes wrong is not my problem!

And for what it's worth - it IS just as easy to use GifCam on Sci Companion, I only made this for fun and education.

That's great!
Maybe you could share the source file(s)?
(maybe even in GitHub?)
Title: Re: Batch export vector draw commands one by one
Post by: cosmicr on October 15, 2020, 06:13:26 PM
That's great!
Maybe you could share the source file(s)?
(maybe even in GitHub?)

At the moment it's a mess of spaghetti code and commented out sections all over the place, as well as the bugs I mentioned - but if I end up fixing it up I'll put the code online.

If you're really interested in how it works I only learned from the FreeSCI documentation on the SCI Wiki, along with my own experiments with a hex editor. I documented everything I learned here:http://sciwiki.sierrahelp.com//index.php?title=Picture_Resource (http://sciwiki.sierrahelp.com//index.php?title=Picture_Resource). I used SFML for the pixel routines and saving to PNG.
Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 17, 2020, 07:01:31 AM
Phil added a GIF exporter to SCI Companion, but it only works if there's a 999.pal. Naturally, no SCI0 game would have a palette resource.

So when I copied this feature, I altered it to use the current picture's embedded palette (SCI1 or better) or a hardcoded CGA. And here's the result.

This is not yet available from the link in my signature.
Title: Re: Batch export vector draw commands one by one
Post by: troflip on October 17, 2020, 11:21:35 AM
You made quick work of that!
Title: Re: Batch export vector draw commands one by one
Post by: Kawa on October 17, 2020, 12:06:52 PM
What is quick work, really? Phil added it twelve hours ago at the time I write this, and I finished backporting it three hours ago.

Edit: I'm an idiot who didn't recognize "troflip". I'm too used to "Phil". Awk-ward~
Title: Re: Batch export vector draw commands one by one
Post by: MusicallyInspired on October 17, 2020, 01:07:43 PM
Lovely! I appreciate this work! :D