Neatest way to save a series of images

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
PhilD
Posts: 6
Joined: Mon 18 May 2020, 09:44

Neatest way to save a series of images

Post by PhilD »

I'm writing a program which produces a series of images (Mandelbrot zoom and scroll, if you need to know. It's been done before, but there we are). Am I right that, to save them in titled numerical order ("frame00001.bmp", "frame00002.bmp", etc.), the neatest way is to *gsave the image and then rename it? And that the neatest way to do that would be something like this (the code in procSaveImage is all I'm looking at here. Long variable names used for clarity)? And would a short WAIT be advisable between the *gsave command and the oscli, just to give it a chance to catch up with itself? I've used WAIT 30, which isn't much of a delay given how long it takes to produce the image in the first place.

Code: Select all

      install @lib$+"STRINGLIB"
      repeat
     *| [image-generating and folder selection code here]

      procSaveImage(ImageTitle$, CurrentFrameNumber%)
      until FrameNumber% = MaxNumberOfImages%
      end

      def procSaveImage(ImageTitle$, CurrentFrameNumber%)

      Rename$ = "rename image.bmp " + ImageTitle$ + fn_tobase(CurrentFrameNumber%, 10, 5) + ".bmp"
      *gsave "image" 0,0,1280,960
      oscli Rename$

      endproc
      return

DDRM
Posts: 185
Joined: Mon 02 Apr 2018, 18:04

Re: Neatest way to save a series of images

Post by DDRM »

Why not just wrap the *GSAVE (equivalent to *SCREENSAVE) in the OSCLI directly, as listed in the manual? Then you don't need to worry about the delay.

Best wishes,

D

PhilD
Posts: 6
Joined: Mon 18 May 2020, 09:44

Re: Neatest way to save a series of images

Post by PhilD »

Ah! Thanks. So something like:

oscli ("gsave ImageTitle$ + fn_tobase(CurrentFrameNumber%, 10, 5) 0,0,1280, 960")

would work?

[edit]

Hmm, no, that doesn't quite work. But I've worked it out now (childcare in lockdown takes up a lot of my brainpower! In any case there's a lag, sometimes of several years, between me reading the manual and understanding it. This is no fault of the author). Thanks again. This does the trick:

Code: Select all

      def procSaveImage(ImageTitle$, CurrentFrameNumber%)

      ImageTitle$ = ImageTitle$ + (fn_tobase(CurrentFrameNumber%, 10, 5))
      x1% = 0 : y1% = 0 : x2% = 1280 : y2% = 960

      oscli "SCREENSAVE """+ImageTitle$+""" "+str$(x1%)+","+str$(y1%)+","+str$(x2%)+","+str$(y2%)

      endproc
      return
Last edited by PhilD on Mon 18 May 2020, 23:14, edited 5 times in total.

DDRM
Posts: 185
Joined: Mon 02 Apr 2018, 18:04

Re: Neatest way to save a series of images

Post by DDRM »

Yes, but if you want to save the whole screen I think you can miss out all the bit about coordinates.

Best wishes,

D

PhilD
Posts: 6
Joined: Mon 18 May 2020, 09:44

Re: Neatest way to save a series of images

Post by PhilD »

Yes, though it's handy to know how to do coordinates, and I might have other info displayed on another part of the screen if I end up adding a GUI, and for speed I do a lot of testing with a very small frame size, usually 160x120, as my code will adapt to any frame size. I tend to reserve full-screen Mandelbrots for single images rather than animations, though the animations I have in mind will be bigger than 640x480.