|
-
Apr 26th, 2005, 09:41 AM
#1
Re: Save a screenshot?
Since your program doesn't have the focus when you want to save the screen. You might want to look into using the RegisterHotKey function to register a hotkey to be used to save the screen. You could then use the code posted by Hack above in the callback function to save the image.
-
Apr 26th, 2005, 10:20 AM
#2
Thread Starter
Addicted Member
Re: Save a screenshot?
What makes you so sure I dont have focus? Like i said, i have already hooked the keyboard for use of it ingame, so i can just press a button and it saves a screen.
so yes i do have focus. i will try the code now, thanks
-
Apr 26th, 2005, 10:22 AM
#3
Re: Save a screenshot?
I'm sorry I didn't read your origional post careful enough.
-
Apr 26th, 2005, 10:33 AM
#4
Thread Starter
Addicted Member
Re: Save a screenshot?
Does anyone know if i could possibly blueprint all these images im saving with some simple text at the bottom or something?
I have the filenames saved based on the time right now.
BTW can i save them as jpg instead of bmp because bmp is large files
-
Apr 26th, 2005, 11:04 AM
#5
Re: Save a screenshot?
You could put the image inside a memory dc and use DrawText and then store it or simply put it in a hidden PictureBox and use the Print statement and then save the image (the PicBox need to have the AutoRedraw property set). To save as a JPG you need some third party control. I think I have a simple BMP2JPG dll somewhere, I'll see if I can dig it out for you.
-
Apr 26th, 2005, 04:43 PM
#6
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Apr 26th, 2005, 05:32 PM
#7
Re: Save a screenshot?
Here's the DirectX approach to saving snapshots. You can save it as bmp as well as jpg or any other format. DirectX does it for you.
VB Code:
Public Sub DirectX_Snapshot(ByVal File_Path As String)
Dim Surface As Direct3DSurface8
Dim SrcPalette As PALETTEENTRY
Dim SrcRect As RECT
Dim Direct3D_Display_Mode As D3DDISPLAYMODE
'get display dimensions
Direct3D_Device.GetDisplayMode Direct3D_Display_Mode
'create a surface to put front buffer on,
'GetFrontBuffer always returns D3DFMT_A8R8G8B8
Set Surface = Direct3D_Device.CreateImageSurface(Direct3D_Display_Mode.Width, Direct3D_Display_Mode.Height, D3DFMT_A8R8G8B8)
'get data from front buffer
Direct3D_Device.GetFrontBuffer Surface
'we are saving entire area of this surface
With SrcRect
.Left = 0
.Right = Direct3D_Display_Mode.Width
.Top = 0
.bottom = Direct3D_Display_Mode.Height
End With
'save this surface to a BMP file
'Direct3DX.SaveSurfaceToFile File_Path, D3DXIFF_BMP, Surface, SrcPalette, SrcRect
'save this surface to a JPG file
Direct3DX.SaveSurfaceToFile File_Path, D3DXIFF_JPG, Surface, SrcPalette, SrcRect
'Here are some more formats
'D3DXIFF_TGA
'D3DXIFF_PNG
'D3DXIFF_DIB
'D3DXIFF_DDS
'D3DXIFF_PPM
'D3DXIFF_FORCE_DWORD <---- Don't know what that does.
End Sub
And in your game loop, you put this in:
VB Code:
'Declare this variable in the General Declarations
Dim Snapshot_Number As Long
'Then put this in your loop
If DirectInput_Key_State(DIK_F12) Then
If Dir$(App.Path & "\Snapshots\", vbDirectory) = "" Then
MkDir App.Path & "\Snapshots\"
End If
If Dir$(App.Path & "\Snapshots\SNAP" & Format(Snapshot_Number, "####") & ".jpg") = "" Then
DirectX_Snapshot App.Path & "\Snapshots\SNAP" & Format(Snapshot_Number, "####") & ".jpg"
End If
While Dir$(App.Path & "\Snapshots\SNAP" & Format(Snapshot_Number, "####") & ".jpg") <> ""
DoEvents
Snapshot_Number = Snapshot_Number + 1
Wend
End If
Last edited by Jacob Roman; Apr 26th, 2005 at 05:46 PM.
-
Apr 26th, 2005, 08:20 PM
#8
Fanatic Member
Re: Save a screenshot?
Hi Jacob Roman,
If any of us want to build a stand alone pgm using your code, is there any other things we need to declare (or know), to build into the pgm.
Your sample aimed at jacob123, assumes that he has Directx 'stuff' already in his pgm (which he has).
Thanks for sharing,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|