• Advertisement
Sign in to follow this  

Saving Snapshots As JPG using DirectX8

This topic is 4678 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using this sub I made to make snapshots as bmp:

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

End Sub

But since I decided to save them as jpeg, there's a problem. After switching it from D3DXIFF_BMP to D3DXIFF_JPG, it locks up and doesn't save at all. I think it has a lot to do with the D3DFMT_A8R8G8B8 format. Is there another DirectX format I need to use for jpegs or is there another way around this? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I don't know if this is the problem or not, but jpegs don't store alpha information. Try using a png (or gif) for alpha, or D3DFMT_X8R8G8B8 for jpegs.

Share this post


Link to post
Share on other sites
Ok now I have a problem. I get an Automation error on this line

Direct3D_Device.GetFrontBuffer Surface

Plus in the comments in my code it says GetFrontBuffer always returns D3DFMT_A8R8G8B8. Any other way?

Share this post


Link to post
Share on other sites
While the save functions take a nice image format parameter, I seem to remember the DX8 docs say that only BMP (and DDS? I can't remember) are supported. DX9 docs seem to say almost everything is supported.

No idea what's wrong with the GetFrontBuffer... sorry.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement