{
  Tony Domigan : http://www.domaj.com : 15Oct02
Using DXLIB save a director cast member bitmap
  In memberNum 0 Of the internal cast To c:\dirpix.bmp.
  Note:
  1. This code does no validation.
     A valid Bitmap Is assumed To be available In the
     first position Of the internal cast.
  2. This code is based On a code snippet provided by
     DelphiXTRA
  Any comments, suggestions Or corrections To tony@domaj.com
  For all DXLIB support: http://www.delphixtra.com
}

Unit exportCastBitmap;

Interface

Uses DXClasses, Windows, Graphics;

Type
  TexportBitmap=Class(TDXScript)
  Protected
    Procedure ExecuteFunction(FunctionIndex:Cardinal; Const ArgList:IDXArgList;
      Const Result:IDXValue); override;
  Public
    Class Procedure GetScriptInfo(Var ScriptInfo:TDXScriptInfo); override;
  End;

Implementation

Const
  CLSID_Script:TGUID='{74C26EC1-E03B-11D6-9139-004F4900150E}';

Class Procedure TexportBitmap.GetScriptInfo(Var ScriptInfo:TDXScriptInfo);
Begin
  ScriptInfo.MessageTable:='xtra exportBitmap'#10+
     '* exportBitmap'#10;
End;

Procedure TexportBitmap.ExecuteFunction(FunctionIndex:Cardinal;
  Const ArgList:IDXArgList; Const Result:IDXValue);

Procedure exportBitmap;
Var
cast : IDXCast;
  member : IDXCastmember;
  // Our offscreen bitmap
  b : TBitmap;
  // the following values will be written to
  // by the GetBitmap function

  DC : HDC;
  bitmap : hBitmap;
  width, height : Integer;
Begin
cast := movie.GetCastByIndex(1); //Internal Cast
  member := cast.CastMember[1]; // assume member 1 has bitmap
  b:=TBitmap.Create; //create an offscreen bitmap
member.Media.GetBitmap(bitmap,DC,width,height);// create our references
  // point our offscreen bitmap to the dib in memory
b.Handle:=bitmap;
  b.Canvas.Handle:=DC;
  Try
b.SaveToFile('c:\dirpix.bmp'); //Save to file
  Finally
b.Free;
  End;
End;

Begin
  Case FunctionIndex Of
  0: exportBitmap;
  End;
End;

Initialization
  RegisterDXClass(TexportBitmap,CLSID_Script);
End.
 
[domaj: 15Oct02] Download the exportCastBitmap.pas file or Download Unit, XTRA and Director 8 demo