Linux2009. 4. 28. 00:40
JPEG 관련 free 라이브러리를 제공하는 홈페이지이다.
검색을 해보니 jpeg decompress를 하면 bmp으로 나오도록 지원을 하는 듯 하다.

/////////////////////////////////////////////////////////////////////////////
// Creation 30/12/2003                                               
// 
// 
//                             JPG2BMP.C
//                             ---------
// 
// 
// Sylvain MARECHAL - sylvain.marechal1@libertysurf.fr
/////////////////////////////////////////////////////////////////////////////
// 
//  Convert a jpg to a bmp file
//  look at jpeg-6b/djpeg.c for more details
// 
/////////////////////////////////////////////////////////////////////////////
#include "cdjpeg.h"		/* Common decls for cjpeg/djpeg applications */
#include "jversion.h"		/* for version message */

#include "ctype.h"		/* to declare isprint() */

#ifdef USE_CCOMMAND		/* command-line reader for Macintosh */
#ifdef __MWERKS__
#include "sioux.h"              /* Metrowerks needs this */
#include "console.h"		/* ... and this */
#endif
#ifdef THINK_C
#include "console.h"		/* Think declares it here */
#endif
#endif
#include "jpg2bmp.h"		/* for version message */


/* Create the add-on message string table. */
/*
#define JMESSAGE(code,string)	string ,

static const char * const cdjpeg_message_table[] = {
#include "cderror.h"
  NULL
};
*/
//#define MAIN
#ifdef MAIN
// The test program
int main( int argc, char * argv[] )
{
    if( argc != 3 )
    {
	printf( "Usage : %s [file_in.jpg] [file_out.bmp]\n" );
	return 1;
    }
    return Jpg2Bmp( argv[1], argv[2] );
}
#endif



int Jpg2Bmp( char * pszJpgFile, char * pszBmpFile )
{
  struct jpeg_decompress_struct cinfo;
  struct jpeg_error_mgr jerr;
  djpeg_dest_ptr dest_mgr = NULL;
  FILE * input_file;
  FILE * output_file;
  JDIMENSION num_scanlines;

  /* Initialize the JPEG decompression object with default error handling. */
  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_decompress(&cinfo);
  /* Add some application-specific error messages (from cderror.h) */
//  jerr.addon_message_table = cdjpeg_message_table;
  jerr.first_addon_message = JMSG_FIRSTADDONCODE;
  jerr.last_addon_message = JMSG_LASTADDONCODE;

  /* Open the input file. */
  if ((input_file = fopen(pszJpgFile, READ_BINARY)) == NULL) {
      return -1;
  }

  /* Open the output file. */
    if ((output_file = fopen(pszBmpFile, WRITE_BINARY)) == NULL) {
      return -1;
    }

  /* Specify data source for decompression */
  jpeg_stdio_src(&cinfo, input_file);

  /* Read file header, set default decompression parameters */
  (void) jpeg_read_header(&cinfo, TRUE);

  /* Adjust default decompression parameters by re-parsing the options */
  //file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);

  /* Initialize the output module now to let it override any crucial
   * option settings (for instance, GIF wants to force color quantization).
   */
    dest_mgr = jinit_write_bmp(&cinfo, FALSE);
  dest_mgr->output_file = output_file;

  /* Start decompressor */
  (void) jpeg_start_decompress(&cinfo);

  /* Write output file header */
  (*dest_mgr->start_output) (&cinfo, dest_mgr);

  /* Process data */
  while (cinfo.output_scanline < cinfo.output_height) {
    num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
					dest_mgr->buffer_height);
    (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
  }

  /* Finish decompression and release memory.
   * I must do it in this order because output module has allocated memory
   * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
   */
  (*dest_mgr->finish_output) (&cinfo, dest_mgr);
  (void) jpeg_finish_decompress(&cinfo);
  jpeg_destroy_decompress(&cinfo);

  /* Close files, if we opened them */
    fclose(input_file);
    fclose(output_file);

  /* All done. */
  return jerr.num_warnings ? -1 : 0;
}


[예제 : ce.sharif.edu/~haghshenas/files/c/jpg2bmp.c]

[공식 : http://www.ijg.org/]
Posted by 구차니