PDA

View Full Version : surface.stretchdraw



Joey
30-07-2003, 02:45 PM
I have a Directdrawsurface of 1024*1024.

I need to draw this into my main surface 512*512. This is what i tried:

dxdraw1.surface.stretchdraw(rect(0,0,512,512),dire ctdrawsurface.ClientRect,directdrawsurface,false);


It wont stretchdraw the directdrawsurface. dxdraw1 is the 'parent' and dxdraw1 has dostretch enabled.

Does some1 know how to stretchdraw correct?

doggo18
31-07-2003, 01:24 PM
I don't have DelphiX installed anymore; however, I think you are doing it wrong. The first parameter specifies a rect of 512x512. But what is the ClientRect doing there? That would give you the forms available size for controls. I am not sure if it is the first or the third parameter that carries the size of the original surface, but I think it should be a rect of 1024x1024..

Hope it helps :)

Joey
01-08-2003, 11:18 AM
procedure TDirectDrawSurface.StretchDraw(const DestRect, SrcRect: TRect; Source: TDirectDrawSurface;
Transparent: Boolean);


first is DESTINATIONrect so should be 512*512.
second is the SOURCErect so should be 1024*1024
third is source

so it seems im doing it right?

Traveler
01-08-2003, 01:03 PM
I do not think the error is in the code you gave us. I have tested it and it works perfectly.


var
Form1: TForm1;
mysurface : Tdirectdrawsurface;
implementation

{$R *.DFM}

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
dxdraw1.surface.stretchdraw(rect (0,0,form1.Width,form1.Height),mySurface.ClientRec t,mySurface,false);
dxdraw1.flip;
end;

procedure TForm1.DXDraw1Initialize(Sender: TObject);
begin
mysurface := TDirectDrawsurface.Create(DXDraw1.ddraw);
mysurface.LoadFromGraphic(DXImagelist1.items.items [0].picture.graphic);
dxtimer1.Enabled:=true;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
mysurface.Free
end;

end.