DOMAJ DXLIB TIPS
CREATE A DIRECTOR BITMAP using THE DXLIB SCRIPT CLASS
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
{
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.
Here is a sample unit in a new window
[domaj: 09Oct02] Download
the createABitmap.pas file or Download
Unit and Director 8 demo
DXLIB TIPS INDEX
- When I use sendMessage, the message does not appear in the Director message window. Why?
- How do I return a value to Director?.
- What is the results interface?
- Field properties.
- How do I trigger the mouseUp handler?
- How do I add my own function to an asset?
- How do I add my own function to a sprite?
- How do I manipulate the score?
- How do I show delphi forms?
- How do I define and use my own variables?
- How do I create and and read global variables and their values?
- How do I create a behavior?
- How do I trigger a script in Director?
- How do I get the properties of a cast member?(31Mar03)
- How do I manipulate casts?
- How do I debug an XTRA?
- How do I draw a castmember icon?
- How do I add my own resource file bitmap as the castmember icon?
- How do I add a Director property interface
- Using the bitmap media property of a castmember (30Apr02)
- How do I return a list to Director (09May02)
- How to create, execute and delete a Director script (08Oct02)
- How to create a Director Bitmap (09Oct02)
- How to export a Director Bitmap (15Oct02)
DOMAJ Links
