{ CREATE A DIRECTOR BITMAP using THE DXLIB SCRIPT CLASS Tony Domigan http://www.domaj.com mailto:tony@domaj.com This unit demonstrates: 1. the creation of a global script for use on Director 2. the creation of a new castmember (of type "bitmap" 3. the assignment of a bitmap to the new member 4. the saving of an offscreen bitmap to disk Comments, suggestions or corrections? email me on tony@domaj.com or visit my site and forums. For all DXLIB support the official address is: http://www.delphixtra.comprocedure script3; } unit createAbitmap; interface uses DXClasses, Windows, Graphics; type Tcreatebmp=class(TDXScript) protected procedure ExecuteFunction(FunctionIndex:Cardinal; const ArgList:IDXArgList; const Result:IDXValue); override; public class procedure GetScriptInfo(var ScriptInfo:TDXScriptInfo); override; class procedure InitializeClass(const Info:TDXInitializeClassInfo); override; end; implementation const CLSID_Script:TGUID='{15E118C1-DB6D-11D6-9139-004F4900150E}'; var aBitmap:TDXSymbol; class procedure Tcreatebmp.GetScriptInfo(var ScriptInfo:TDXScriptInfo); begin ScriptInfo.MessageTable:='xtra createbmp'#10+ '* createbmp'#10; end; class procedure Tcreatebmp.InitializeClass(const Info:TDXInitializeClassInfo); begin aBitmap:=info.SymbolManager.CreateSymbol('BITMAP'); end; procedure Tcreatebmp.ExecuteFunction(FunctionIndex:Cardinal; const ArgList:IDXArgList; const Result:IDXValue); procedure createbmp; var newBitmap : TBitMap; cast : IDXCast; member : IDXCastmember; unused : Integer; begin //Default to the internal cast cast := movie.GetCastByIndex(1); // Get first free member slot unused := cast.FindFreeMemberIndex(1); // Create a bitmap member member := cast.CreateCastMember(unused,aBitmap); // Create an offscreen bitmap of a size to match our drawing newBitmap := TBitmap.Create; newBitmap.Width := 50; newBitmap.Height := 50; try // Draw on the offscreen bitmap canvas with newBitmap do begin Canvas.Brush.Color := clRed; Canvas.Brush.Style := bsDiagCross; Canvas.Ellipse(0, 0, 50, 50); end; // Assign to offscreen botmap to the castmember member.media.SetBitmap(newBitmap.Handle,true); // Save the offscreen bitmap to disk // Note: we are not saving the member! newBitmap.SaveToFile('c:\createbmp.bmp'); finally // Destroy the offscreen bitmap newBitmap.Free; // Return the memberNum to Director result.Integer := unused; end; end; begin case FunctionIndex of 0: createbmp; end; end; initialization RegisterDXClass(Tcreatebmp,CLSID_Script); end.