Images saved with D3DXSaveSurfaceToFile will open in Paint, not Photoshop

Posted by bsruth on Stack Overflow See other posts from Stack Overflow or by bsruth
Published on 2010-03-18T21:47:12Z Indexed on 2010/03/18 21:51 UTC
Read the original article Hit count: 275

Filed under:
|
|

I'm using D3DXSaveSurfaceToFile to save windowed Direct3D 9 surfaces to PNG, BMP and JPG files. There are no errors returned from the D3DXSaveSurfaceToFile call and all files open fine in Windows Photo Viewer and Paint. But they will not open in a higher end image editing program such as Paint Shop Pro or Photoshop. The error messages from these programs basically say that the file is corrupted. If I open the files in Paint and then save them in the same file format with a different file name, then they'll open fine in the other programs.

This leads me to believe that D3DXSaveSurfaceToFile is writing out non-standard versions of these file formats. Is there some way I can get this function to write out files that can be opened in programs like Photoshop without the intermediate step of resaving the files in Paint? Or is there another function I should be using that does a better job of saving a Direct3D surfaces to an image?

© Stack Overflow or respective owner

Related posts about directx

Related posts about images