Advertisement

Using Directx and Jpegs

Started by April 09, 2002 02:55 AM
7 comments, last by loadexfa 22 years, 5 months ago
Hello, I''m having trouble loading jpeg files to a directx 7 surface using Intel''s jpeg library. I read the snippet and used the source code to get started (from this site) but the sample didn''t account for something in my jpeg and I had to modify the code to allow for different numbers of channels to work with my pics. Now, when I load images, sometimes it works perfectly, and other times the images are skewed at an angle as if someone pressed the itallic button on my image. It looks really wierd. Any help would be greatly appreciated. If source code or a sample skewed image would help please let me know. Thank you in advance. Josh
Skewed angle? Sounds like a pitch vs width problem.

Basically DirectDraw likes each row of an image to be aligned to 4 bytes (I think).

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Advertisement
Hmm, I kinda see what you mean. Can you go into more detail or somewhere to look? Thanks
If you have the DirectDraw SDK docs installed (before DX8), they have detailed information on surface pitch and width.

If not, try Google or the online MSDN!

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
I''ve looked into it and it doesn''t look like a pitch issue. First of all, it works for some jpegs, and not others. Of course it doesn''t work for the one I need to use with my sprite images in it. From looking at the directx docs, I only need pitch if I''m accessing the memory for things like plotting a pixel. I''m just copying a DIB to a surface and then blitting the surface. Could there be a pitch problem in the DIB?

Thank you for your responses so far.
The pitch problem is where you ask DirectDraw to create a surface that is so many pixels wide, it then rounds it up to a multiple of 4 bytes (or whatever).

So that means you WILL get the problem for some pics but not all.

If at any point you''re copying an image line by line you have to think about pitch on the destination surface instead of using the width of the source.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Advertisement
Hmm, I''m using
DDCopyBitmap(*Surface, hbm, 0, 0, 0, 0);
to copy the bitmap to the surface...maybe I should add a pitch buffer for each row of hbm? I''ll mess with that.
Just check to see if that function handles pitch properly. If so, your problem is perhaps in your JPG loading.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
The D3DX Library provides functions for loading files such as jpegs, although I won''t look up the function right now. Someone else care to point him to it?

____________________________________________________________
Direct3D vs. OpenGL
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement