Jpegs in Directx

Started by
18 comments, last by UHHH Internet 18 years, 4 months ago
How do you use JPEG images in directx. I am using directx 9.0. Thanks in advance.
Advertisement
You can just use the D3DX functions for loading them - D3DX supports them out-of-the-box. You can also save JPGs using D3DXSaveTextureToFile/D3DXSaveSurfaceToFile.
Can you play animations in the same way?
JPEGs don't contain animations.

You can, however, load a couple of JPEG files into different textures and just display them in order.
Are you sure? I just made a jpeg animation with photoshop.
It could have a jpg extension but be in GIF file format.
OOOO, well is there any way I can use that in Directx?
OOOO, well is there any way I can use that in Directx?
Nope. You will have to do that manually, which isn't that hard to do.
You just create your animation as usual and either save the frames to single images (easier to do that first) or assemble them into a single image layout into rows and columns of single frames.
In your game you load this image (or the the single images) along with extra information about time to next frame (or just a single frame-rate).
In your render loop you would then get the time that elapsed since the last frame and add that to an animation timer. If this timer equals or exceeds your animation frame rate you would switch to the next image and reset your animation timer to zero.
The last frame of animation has then to be treated in a special way, e.g. keeping it for one-shot animations or simply setting the animation frame counter back to zero for loops, etc. - you'll figure that out once you get started with it.
How do you make it into sigle bitmap images?

This topic is closed to new replies.

Advertisement