Loading or converting a jpg

Started by
3 comments, last by george135 15 years, 5 months ago
After alot of searching and alot of dead ends I have decided to just ask and hope for the best, I am trying to load a jpg to a direct x surface using c++. The problem is for all the sites on google about this, they dont really help. And most were written back in 02 and 03 and mention sites that no longer exist. Now I don't care if its a jpg when it hits the surface, or if you know a way to simple convert it to a bmp. I just want a point in the right direction. anyone? Thanks, Matt
Advertisement
Well, you can use an external program to convert the jpg to a bmp if that helps you. For example, IrfanView is free and can do this.
There's no such thing as a "DirectX surface". There is however DirectDraw surfaces and Direct3D surfaces. If you're using Direct3D, there's D3DXLoadSurfaceFromFile. If you're using DirectDraw, then you'll have to do the JPEG decoding yourself - which is one of the many reasons that DirectDraw is not recommended, and rendering 2D with Direct3D is preferable.
I think the Texture tool in dxsdk can do it too. dds is fine too.

Or you could do your own converter with D3DXCreateTextureFromFile() and D3DXSaveTextureToFile(). This function supports the following file formats: .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, and .tga.
You don't need anything to convert a JPG to any format.
Just use Win32 api (SH), 1 line of code

This topic is closed to new replies.

Advertisement