PDA

View Full Version : Screen shots



cairnswm
30-01-2003, 07:10 AM
I'm using the standard DXDraw component. How do I generate a Screen Dump of my screen? I could do it pixel by pixel but I'm sure there is an easier way.

All I want is a bmp file on my harddrive when the user presses a key....

Cheers

TheLion
30-01-2003, 09:31 AM
theoretically you could use the handle (think DXDraw has one) of the TDXDraw component and use the same method used to make a screenshot, but instead of the Desktop Handle you simply use the TDXDraw handle...

I never did this so it's all just theoretically...

Another solution might be the DXDraw surface, I'm not sure (I have computer problems on my pc with Delphi on it, so I can't look cq. test it) but I think it has the SaveToFile option, like the TBitmap component.

cairnswm
30-01-2003, 12:16 PM
Found the way :)

B := TBitMap.Create;
B.Width := VideoModeX;
B.Height := VideoModeY;
B2 := TBitMap.Create;
B2.Width := VideoModeX div 2;
B2.Height := VideoModeY div 2;
B.Canvas.CopyRect(Rect(0,0,VideoModeX-1, VideoModeY-1),DXDraw1.Surface.Canvas,Rect(0,0,VideoModeX-1, VideoModeY-1));
B2.Canvas.StretchDraw(Rect(0,0,B2.Width-1, B2.Height-1), B);
B.SaveToFile('TEST.BMP');
B2.SaveToFile('TestSmall.bmp');
B.Free;
B2.Free;

Works well with hardly a flicker on the screen.

If someone can tell me how to post an image I'll put a screen dump of two on the projects forum.

Useless Hacker
30-01-2003, 12:49 PM
If someone can tell me how to post an image I'll put a screen dump of two on the projects forum.
You'll need to upload it to some webspace, then use:
http://yoursite/imagename

P.S. Remember to call DXDraw1.Surface.Release after using the Canvas.