I made a subroutine to save a buffer used in tinyptc to an uncompressed .tga file for use as a screenshot function. Since it's stand alone and relies on nothing in the TTDblitzlib it should be useable by other people as well.
'-------------------------------------------------------------------
' NAME : TTDSaveTGA
' PURPOSE : This function Saves Buffer to TGA format Image
' INPUTS : filename$, width and height then the buffer.
' RETURNS : Nothing.
'-------------------------------------------------------------------
Sub TTDSaveTGA(byval Filename as string,byval s_width as short,byval s_height as short,byval i_buffer as integer ptr )
dim as short s_temp
dim as byte b_temp
dim as integer i_temp
If Right$(Filename,4)<>".tga" then
Filename=Filename+".tga"
EndIf
' Setup and open file
f=FREEFILE
OPEN Filename FOR BINARY AS #f
b_temp=0
s_temp=0
' Start outputing TGA header
PUT #f,,b_temp 'idlength
PUT #f,,b_temp 'colormaptype
b_temp=2
PUT #f,,b_temp 'imagetype 2=rgb
PUT #f,,s_temp 'colormapindex
PUT #f,,s_temp 'colormapnumentries
b_temp=0
PUT #f,,b_temp 'colormapsize
PUT #f,,s_temp 'xorigin
PUT #f,,s_temp 'yorigin
PUT #f,,s_width 'width
PUT #f,,s_height 'height
b_temp=32
PUT #f,,b_temp 'pixsize
b_temp=8
PUT #f,,b_temp 'attributes
For y=s_height-1 To 0 Step -1
For x=0 To s_width-1
i_temp=i_buffer[(y*s_width+x)]
PUT #f,,i_temp
Next
Next
CLOSE #f
End Sub
Call the sub like so TTDSaveTGA("Test",640,480,@Backbuffer[ 0 ] ) were Backbuffer is your array or memory area for the buffer you send to ptc_update.
Note you might not need the [ 0 ] bit or it might need to be ( 0 ) depends how you set up your area for the buffer you draw to,also only send correct width and height or you will get garbage ;)
Thanks for sharing. This will be useful once I get around to actually finishing something in FB :)
Cool :) Thanks for sharing Jon.
Thanks guys, uncompressed tga's are a tad big but for screenshots they can be converted to jpg's etc. I could code a loader to do the reverse if anyone is interested but not really sure it's worth it since the pic files included would be massive :D
Still really handy for people who want to take screen shots. I usually use irfanview to do a screen grab but not everyone has a program to do that so kudos.