SWF to Image Library is an ActiveX/NET Library for Converting SWF (Flash) Movies into BMP, JPEG, GIF Image Files - ByteScout

SWF to Image Library is an ActiveX/NET Library for Converting SWF (Flash) Movies into BMP, JPEG, GIF Image Files

  • Home
  • /
  • SWF to Image Library is an ActiveX/NET Library for Converting SWF (Flash) Movies into BMP, JPEG, GIF Image Files

SWF to Image Library Features

Requirements: Macromedia Flash plugin installed.

Custom Parameters Description

A detailed description of custom parameters (they are used with a filename to help customize SWF to image conversion using SWF To image):

FORBID_INTERNAL_DOWNLOAD:// tells to let flash player plugin download movie by itself

When a movie loads XML or other data you may need to delay the load of the movie
You can set a timeout in seconds (using PRELOAD prefix) and you can also use 2 different approaches to detect when all data is loaded.

 

Approach #1: If you are not able to recompile source SWF flash movie


DETECT_READY when library tries to detect objects loaded and then convert the frame into jpeg after all objects were loaded successfully

DETECT_READY:// – with this prefix library tries to detect the first object loaded and then go to conversion into image
DETECT_READY2://
DETECT_READY3://

DETECT_READY200:// – you can set the number of objects to wait for before conversion

IMPORTANT NOTE: DETECT_READY prefix can not be used as a standalone prefix. It should be used with PRELOAD:// prefixes as they set “timeout” time to go to conversion even if not object were not loaded

Example 1: (wait for 2 objects, global timeout is 5 sec):
SWFToImage.InputSWFFileName = “PRELOAD5://PRELOAD_READY2://imageTest.swf”

Example 2: (wait for 1 object, global timeout is 2 sec):
SWFToImage.InputSWFFileName = “PRELOAD2://PRELOAD_READY://imageTest.swf”

 

How to detect how many objects the movie is about to load?


This is possible via a built-in hack:

Use GET_READY_TIMES:// prefix and the library will return a number of objects actually loaded in the .ImageWidth property

 

Example (get a number of objects actually loaded in SWF)


Set SWFToImage = CreateObject(“SWFToImage.SWFToImageObject”)
SWFToImage.InitLibrary “demo”, “demo”
SWFToImage.InputSWFFileName = “PRELOAD7://GET_READY_TIMES://test.swf”
SWFToImage.ImageOutputType = 1
SWFToImage.Execute_Begin
SWFToImage.Execute_GetImage
SWFToImage.Execute_End
MsgBox “Number of Objects actually loaded=” & CStr(SWFTOImage.ImageWidth)

 

Approach #2: you can use FSCommand (calling in ActionScript inside your flash movie) to indicate that loading is completed


First insert the following ActionScript code inside the movie to indicate that all data is ready and so loading is done: fscommand(“SWFToImage_LoadingIsDone”);

Then in code that uses SWFToImage library use the following prefix:
USE_FSCOMMAND_TO_DETECT_LOADING_IS_DONE://

This prefix tells the library to wait for the “SWFToImage_LoadingIsDone” command from the Flash movie and then convert the movie into an image immediately.

 

Example


SWFToImage.InputSWFFileName = “PRELOAD10://USE_FSCOMMAND_TO_DETECT_LOADING_IS_DONE://MovieDisplayPassedVar.swf?Variable1=Testing%20Value%20for%20parameter”

IMPORTANT: you should use PRELOAD prefix along with USE_FSCOMMAND_TO_DETECT_LOADING_IS_DONE prefix so library will have a timeout setting for the conversion (in example above it uses 10 seconds timeout setting)

Example (create a movie with actionscript command indicating that loading is done. Code uses SWF Scout library to generate SWF flash movie ):

W = 640
H = 480
FPS = 12
Set Movie = CreateObject(“SWFScout.FlashMovie”)
Movie.InitLibrary “demo”,”demo”
Movie.BeginMovie 0,0,W,H,1,FPS,6

Font = Movie.AddFont( “Arial”,26,true,false,false,false,0)
Text= Movie.AddTextEdit (“edText”,”undefined”,255,100,0,255,Font,10,70,500,120)

Movie.PlaceText Text,DepthForText ‘ place text
Movie.AddScript
Movie.SCRIPT_Compile “if(_root.Variable1!=undefined){edText=_root.Variable1;}else{edText = ‘Variable1 not set’;};”

Movie.ShowFrame 1
Movie.AddScript
Movie.SCRIPT_GetUrl “FSCommand:SWFToImage_LoadingIsDone”, “” ‘ indicate loading is done
Movie.ShowFrame 1
Movie.EndMovie
Movie.SaveToFile “MovieDisplayPassedVar.swf”

 

Using fixed preload delay time


PRELOAD:// – with this prefix flash movie is loaded with a little delay
PRELOAD05:// – with this prefix flash movie is loaded with 500 ms delay
PRELOAD1:// – with this prefix flash movie is loaded with 1000 ms delay
PRELOAD15:// – with this prefix flash movie is loaded with 1500 ms delay
PRELOAD2:// – with this prefix flash movie is loaded with 2000 ms delay
PRELOAD25:// – with this prefix flash movie is loaded with 2500 ms delay
PRELOAD3:// – with this prefix flash movie is loaded with 3000 ms delay
PRELOAD35:// – with this prefix flash movie is loaded with 3000 ms delay
PRELOAD4:// – with this prefix flash movie is loaded with 4000 ms delay
PRELOAD45:// – with this prefix flash movie is loaded with 4500 ms delay
PRELOAD5:// – with this prefix flash movie is loaded with 5000 ms delay
PRELOAD55:// – with this prefix flash movie is loaded with 5500 ms delay
PRELOAD6:// – with this prefix flash movie is loaded with 6000 ms delay
PRELOAD65:// – with this prefix flash movie is loaded with 6500 ms delay
PRELOAD7:// – with this prefix flash movie is loaded with 7000 ms delay
PRELOAD75:// – with this prefix flash movie is loaded with 7500 ms delay
PRELOAD8:// – with this prefix flash movie is loaded with 8000 ms delay
PRELOAD85:// – with this prefix flash movie is loaded with 8500 ms delay
PRELOAD9:// – with this prefix flash movie is loaded with 9000 ms delay
PRELOAD95:// – with this prefix flash movie is loaded with 9500 ms delay
PRELOAD10:// – with this prefix flash movie is loaded with 10000 ms delay
PRELOAD150:// – with this prefix flash movie is loaded with 15000 ms delay
PRELOAD200:// – with this prefix flash movie is loaded with 20000 ms delay

 

Example Code (using fixed preload time)


Set SWFToImage = CreateObject(“SWFToImage.SWFToImageObject”)
SWFToImage.InputSWFFileName = “PRELOAD1://movie_with_dynamic_data.swf”
SWFToImage.ImageOutputType = 1 ‘ set output image type to Jpeg (0 = BMP, 1 = JPG, 2 = GIF)

SWFToImage.Execute_Begin ‘ start conversion
SWFToImage.FrameIndex = 1 ‘ set frame index
SWFToImage.Execute_GetImage
SWFToImage.SaveToFile “movie_with_dynamic_data.jpg”
SWFToImage.Execute_End ‘ end conversion

Example Code (switching library to use flash player engine download engine instead of library built-in engine)


Set SWFToImage = CreateObject(“SWFToImage.SWFToImageObject”)
SWFToImage.InputSWFFileName = “FORBID_INTERNAL_DOWNLOAD://PRELOAD1://movie_with_dynamic_data.swf?myparam=123”
SWFToImage.ImageOutputType = 1 ‘ set output image type to Jpeg (0 = BMP, 1 = JPG, 2 = GIF)

[socialpug_share]