TGC Codebase Backup



ScreenDump by Ade

15th Feb 2005 19:14
Summary

Save screen display to disk using a sequential numbered file.



Description

By default it saves out a sequence numbered file in the current directory. This will not overwrite any existing screendumps in the directory as it checks each time it saves the file to determine the next number. The first screendump will be called dump0001.bmp.

Saving out a BMP is faster than JPG but does produce a much larger file (obviously!). Also it does save an exact copy of the screen unlike JPEG which can have artifacts or colour distortion.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    #constant SCREENDUMP_IMAGE_NUMBER 20000

function ScreenDump()
   rem determine next screendump filename
   ScreenDumpFileNumber = 0
   repeat
      inc ScreenDumpFileNumber

      Filename$ = "dump"
      if ScreenDumpFileNumber < 10   then Filename$ = Filename$ + "0"
      if ScreenDumpFileNumber < 100  then Filename$ = Filename$ + "0"
      if ScreenDumpFileNumber < 1000 then Filename$ = Filename$ + "0"
   
      rem the filename extension determines how it is saved, BMP, DIB or JPG
      Filename$ = Filename$ + str$(ScreenDumpFileNumber) + ".bmp"
   until (file exist(Filename$) = 0)

   temp = current bitmap()
   if temp > 0 then set current bitmap 0 ; rem ensure that we are grabbing the screen image (ie bitmap 0)
   
   get image SCREENDUMP_IMAGE_NUMBER, 0, 0, screen width(), screen height(), 1
   save image Filename$, SCREENDUMP_IMAGE_NUMBER
   
   delete image SCREENDUMP_IMAGE_NUMBER
   if temp > 0 then set current bitmap temp ; rem ensure that we re-instate the previous bitmap drawing destination
endfunction