|
|
|
ScreenCapture
Added on 12/4/2003
|
You could use Sharps image xtra to save screenshots of the stage to the disk at runtime, sure, the movie will slow down during footage, but the result will look good
after creating a video of it. http://www.sharp-software.com
Here is a script that uses it. You can save in 3 diffrent formats depending on os. you can set name and
number of chars used in framenaming.
its set to capture in 16bit
-- @name ScreenCapture
-- @type parent
-- @version 0.1
-- @author Christoffer Enedahl
-- @Dependencies Sharp Image Export Xtra http://www.sharp-software.com
-- @description a screencapture script to use with Sharps Image exporter
-- @description you can save in 3 diffrent formats depending on os. you can set name and
-- @description its set to capture in 16bit
--
-- @usage -- Initiate
-- @usage gScreenCapture = script("ScreenCapture").new()
-- @usage gScreenCapture.SetFileType( "bmp" )
--
-- @usage -- Take picture, perhaps in a keydown script, or keypressed for continual capture
-- @usage gScreenCapture.SaveFrame()
--
-- @usage --clean up
-- @usage gScreenCapture.terminate()
property pMember
property pXtra
property pFrame
property pErrCodes
property pName
property pNumChar
property pCompression
property pFileType
on new me
pMember = new(#bitmap)
pMember.name = "ScreenCapturePlaceholder"
pXtra = new (xtra "SharpExport")
pFrame = 0
pName = the moviename
pNumChar = 5
pCompression = 80
pFileType = "png"
pErrCodes = ["destination file can not be written",
"out of memory","wrong number of args","bad parameter",
"castmember not found","castmember media not found",
"castmember is not a bitmap","unsupported bitdepth (JPEG
support is 8 bits or higher)",
"JPEG compression failed (internal error with JPEG
library)",
"PNG compression failed (internal error with PNG library)"]
vRect = the stage.Rect
pMember.image = image(vRect.width, vRect.height,16)
return me
end
on SetName me,aName
pName = aName
end
on SetCharNum me,aNum
pNumChar = aNum
end
on SetFileType me, aFileType
case aFileType of
"png","jpg" :
pFileType = aFileType
return true
"bmp":
if the environment.platform contains "mac" then return false --not
supported in macintosh
pFileType = aFileType
return true
"pct":
if the environment.platform contains "win" then return false --not
supported in windows
pFileType = aFileType
return true
End case
return false
end
on SaveFrame me
pFrame = pFrame + 1
vRect = the stage.Rect
pMember.image.copyPixels( (the stage).image, rect(0,0,vRect.width,
vRect.height), rect(0,0,vRect.width, vRect.height))
vStr = string(pFrame)
repeat while vStr.length < pNumChar --Numeric chars
vStr = "0"& vStr
end repeat
vFilePath = the moviepath & pName & vStr & "."& pFileType
case pFileType of
"jpg":
errCode = pXtra.exportJPG(pMember, vFilePath , min(100,max(1,
pCompression)) )
"PNG":
errCode = pXtra.exportPNG(pMember, vFilePath)
"BMP": -- win only
errCode = pXtra.exportBMP(pMember, vFilePath)
"PCT": -- mac only
errCode = pXtra.exportPICT(pMember, vFilePath)
end case
if errCode <> 0 then me.showError(errCode)
end
on showError me, errCode
if the runMode <> "Author" then
alert "An error has occurred while exporting the image." & RETURN & "The
error code is: " & errCode & RETURN & RETURN & "Image export failed."
else
alert "An error has occurred while exporting the image." & RETURN &
RETURN & "The error code is: " & errCode & RETURN & pErrCodes[abs(errCode)]
& RETURN & RETURN & "Image export failed."
end if
end
on terminate me
pMember.erase()
pMember = void
pXtra = void
end
|
|