Results 1 to 4 of 4

Thread: surface.stretchdraw

  1. #1

    surface.stretchdraw

    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?

  2. #2

    surface.stretchdraw

    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

  3. #3

    surface.stretchdraw

    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?

  4. #4

    surface.stretchdraw

    I do not think the error is in the code you gave us. I have tested it and it works perfectly.

    Code:
    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.ClientRect,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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •