I did play around with Mage's example a bit... The codes a bit messy now but I think this still works, its a lot quicker. Have a look.
REM Project: TransparentScreenshot_Demo
REM Created: 4/27/2011 9:47:16 AM
REM Version: 1.3b
REM Created By: Mage
REM ***** Main Source File *****
REM
`Setup the display
Set Display Mode desktop width(), desktop height(), 32
Sync on : sync rate 0
autocam off : Backdrop on
global camdist = -150
position camera 0,0,camdist
`Setup a simple scene
load object "Knight (Unarmed).X",10
Set ambient light 70
ShowTransparent = 1
IK Reset Image Kit
ik load effect "RenderTransparent.fx", 1
MyImage = reserve free image()
global tx#=0.0
global ty#=-10000.0
global tz#=0.0
`Generate Black Image
Global BlackImg as integer
Global WhiteImg as integer
BlackImg = reserve free image()
WhiteImg = reserve free image()
Make Camera 1
` SET CAMERA ASPECT 1, AspectRatio#
Set Camera Fov 1,60
Set camera Range 1, 1, camdist*1.5
Position Camera 1, 0, -10000 ,camdist
Backdrop on 1
Color Backdrop 1, RGB(0,0,0)
Make Camera 2
` SET CAMERA ASPECT 2, AspectRatio#
Set Camera Fov 2,60
Set camera Range 2, 1, camdist*1.5
Position Camera 2, 0, -10000 ,camdist
Backdrop on 2
Color Backdrop 2, RGB(255,255,255)
`Handle a Simple Scene to provide the example
Do
`Record the time so we can control the frame rate
FrameTime = HiTimer()
`Setup some simple controls
` CONTROL CAMERA USING ARROWKEYS 0, .1, 1
MyImage = SnapShot(256,512,MyImage,10)
`Alternate between showing image transparency on screen with right mouseclick
If MouseClick() = 2
Inc ShowTransparent
If ShowTransparent > 1 Then ShowTransparent = 0
While MouseClick() = 2
EndWhile
EndIf
inc camdist,mousemovez()/100
if controlkey()
if upkey() then inc ty#,0.1
if downkey() then dec ty#,0.1
if leftkey() then dec tx#,0.1
if rightkey() then inc tx#,0.1
endif
text 0,15,"FPS: "+str$(screen fps())
`Paste the Image if it exists
If MyImage > 0 Then Paste Image MyImage, 10, screen height() - 522, ShowTransparent
`Rotate the example object
YRotate Object 10, Object Angle Y(10) + 0.1
`Update the screen
Sync Mask 0x00000001
sync
loop
`This function sets up 2 cameras to Take a single screen grab with a transparent background.
`The same scene is captured with a pure white and pure black background, then both images are compared to produce the final image.
Function SnapShot(sizeX, sizeY, wImg, Obj)
`Setup Control Variables
AspectRatio# = (sizeX*1.0) / (sizeY*1.0)
`Illegal Dimensions - Limited by use of Get Image commands below.
If sizeX > Screen Height() or sizeX < 1 Then ExitFunction -1
If sizeY > Screen Height() or sizeY < 1 Then ExitFunction -1
If Object Exist(Obj) = 0 Then ExitFunction -1
MyObj = reserve free Object()
instance Object MyObj,Obj
position Object MyObj,tx#,ty#,tz#
rotate Object myObj,0,0,0
`Generate Black Image
SET CAMERA ASPECT 1, AspectRatio#
Set Camera to Image 1, BlackImg, sizeX, sizeY
`Generate White Image
SET CAMERA ASPECT 2, AspectRatio#
Set Camera to Image 2, WhiteImg, sizeX, sizeY
Sync Mask 0x00000006
fastSync
`Use Image Kit to Render Final Image
ik set effect texture 1, "g_Black", BlackImg
IK Set Blend Mode 19
IK Create Render Target wImg, sizeX, sizeY
IK Paste Image On Image WhiteImg, wImg, 0, 0, sizeX, sizeY, 1
`Cleanup
Delete Object myobj
EndFunction wImg