Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Loading and Saving JPEG files in Visual C++?

This topic is 6250 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

Hi there! Can anyone give me the code for loading and saving JPEG files in a Visual C++ SID program? I know there''s some libraries out there, but most of them ain''t focused and there''s no documentation on how to INTEGRATE it into your own program. Thanks a lot!!!

Share this post

Link to post
Share on other sites
jpgs are a nasty combination of RLE runs, DCT (Discrete Cosine Transform) compression, and god knows what else (there are various different types) - if you cant figure out how to use the libraries and you cant roll your own given the info in The Programmers File Format Reference then you are probably better off using simpler formats like bmp, pcx, ppm, tga etc.

Share this post

Link to post
Share on other sites
Use the "Intel Jpeg Library" to load JPEG files. It could be found at the Intel homepage. (www.intel.com)

It easy to use and extreme fast!
Here some code to load in a jpg-File with this library:

typedef struct
char byFilename[256]; // The filename of the texture
BYTE *pbyData; // The texture data
int iColorDepth; // Color depth
int iWidth, iHeight; // The size of the texture
int iID; // The ID
GLuint iOpenGLID; // The OpenGL ID
int iUsed; // How often is this texture used?


BOOL ASLoadJpegRGB(AS_TEXTURE *texture, char* fileName)
{ // begin ASLoadJpegRGB()

memset(&jcProps, 0, sizeof(JPEG_CORE_PROPERTIES));
jcProps.JPGFile = fileName;
ijlRead(&jcProps, IJL_JFILE_READPARAMS);
texture->iWidth = jcProps.JPGWidth;
texture->iHeight = jcProps.JPGHeight;
texture->pbyData = (BYTE *) malloc(sizeof(BYTE)*texture->iWidth*texture->iHeight*3);
jcProps.DIBWidth = jcProps.JPGWidth;
jcProps.DIBHeight = jcProps.JPGHeight;
jcProps.DIBChannels = 3;
jcProps.DIBColor = IJL_RGB;
jcProps.DIBPadBytes = 0;
jcProps.DIBBytes = (BYTE *) texture->pbyData;
jcProps.JPGColor = IJL_YCBCR;
return 1;
return 0;
} // end ASLoadJpegRGB()

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!