Slion.net>Dev>JpegFormat

JPEG Format

Links

Here are provided links about the JPEG format:

IJG code download

You can download from here the latest code from the Independent Jpeg Group.

Build IJG code using Visual Studio 8 command line

Those build instructions were taken from social.msdn.microsoft.com/Forums

Create Visual Studio 8 IDE project for IJG code

You should then be able to debug the IJG code from your IDE.

See How to: Create a C++ Project from Existing Code

Adding buffer source manager to libjpeg

To support decoding jpeg from a memory buffer you could just add a file called jbufdatasrc.c with the following content. You will also need to add the function prototype for jpeg_buffer_src in your jpeglib.h.

#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"



METHODDEF(void)
init_source (j_decompress_ptr cinfo)
{
/*SL: How to throw an error from there?*/
}


METHODDEF(boolean)
fill_input_buffer (j_decompress_ptr cinfo)
{
/*SL: How to throw an error from there?*/
  return FALSE;
}


METHODDEF(void)
skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
/*SL: How to throw an error from there?*/
}

METHODDEF(void)
term_source (j_decompress_ptr cinfo)
{
  /* no work necessary here */
}

GLOBAL(void)
jpeg_buffer_src (j_decompress_ptr cinfo, JOCTET* inbuffer, size_t bytes_in_buffer)
{
  struct jpeg_source_mgr* src;

  if (cinfo->src == NULL) {   /* first time for this JPEG object? */
    cinfo->src = (struct jpeg_source_mgr *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
              SIZEOF(struct jpeg_source_mgr));
  }

  src = cinfo->src;
  src->init_source = init_source;
  src->fill_input_buffer = fill_input_buffer;
  src->skip_input_data = skip_input_data;
  src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
  src->term_source = term_source;
  src->next_input_byte = inbuffer;
  src->bytes_in_buffer = bytes_in_buffer;
}