JPEG 관련 free 라이브러리를 제공하는 홈페이지이다.
검색을 해보니 jpeg decompress를 하면 bmp으로 나오도록 지원을 하는 듯 하다.
[예제 : ce.sharif.edu/~haghshenas/files/c/jpg2bmp.c]
[공식 : http://www.ijg.org/]
검색을 해보니 jpeg decompress를 하면 bmp으로 나오도록 지원을 하는 듯 하다.
001 | ///////////////////////////////////////////////////////////////////////////// |
002 | // Creation 30/12/2003 |
003 | // |
004 | // |
005 | // JPG2BMP.C |
006 | // --------- |
007 | // |
008 | // |
009 | // Sylvain MARECHAL - sylvain.marechal1@libertysurf.fr |
010 | ///////////////////////////////////////////////////////////////////////////// |
011 | // |
012 | // Convert a jpg to a bmp file |
013 | // look at jpeg-6b/djpeg.c for more details |
014 | // |
015 | ///////////////////////////////////////////////////////////////////////////// |
016 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ |
017 | #include "jversion.h" /* for version message */ |
018 |
019 | #include "ctype.h" /* to declare isprint() */ |
020 |
021 | #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ |
022 | #ifdef __MWERKS__ |
023 | #include "sioux.h" /* Metrowerks needs this */ |
024 | #include "console.h" /* ... and this */ |
025 | #endif |
026 | #ifdef THINK_C |
027 | #include "console.h" /* Think declares it here */ |
028 | #endif |
029 | #endif |
030 | #include "jpg2bmp.h" /* for version message */ |
031 |
032 |
033 | /* Create the add-on message string table. */ |
034 | /* |
035 | #define JMESSAGE(code,string) string , |
036 |
037 | static const char * const cdjpeg_message_table[] = { |
038 | #include "cderror.h" |
039 | NULL |
040 | }; |
041 | */ |
042 | //#define MAIN |
043 | #ifdef MAIN |
044 | // The test program |
045 | int main( int argc, char * argv[] ) |
046 | { |
047 | if ( argc != 3 ) |
048 | { |
049 | printf ( "Usage : %s [file_in.jpg] [file_out.bmp]\n" ); |
050 | return 1; |
051 | } |
052 | return Jpg2Bmp( argv[1], argv[2] ); |
053 | } |
054 | #endif |
055 |
056 |
057 |
058 | int Jpg2Bmp( char * pszJpgFile, char * pszBmpFile ) |
059 | { |
060 | struct jpeg_decompress_struct cinfo; |
061 | struct jpeg_error_mgr jerr; |
062 | djpeg_dest_ptr dest_mgr = NULL; |
063 | FILE * input_file; |
064 | FILE * output_file; |
065 | JDIMENSION num_scanlines; |
066 |
067 | /* Initialize the JPEG decompression object with default error handling. */ |
068 | cinfo.err = jpeg_std_error(&jerr); |
069 | jpeg_create_decompress(&cinfo); |
070 | /* Add some application-specific error messages (from cderror.h) */ |
071 | // jerr.addon_message_table = cdjpeg_message_table; |
072 | jerr.first_addon_message = JMSG_FIRSTADDONCODE; |
073 | jerr.last_addon_message = JMSG_LASTADDONCODE; |
074 |
075 | /* Open the input file. */ |
076 | if ((input_file = fopen (pszJpgFile, READ_BINARY)) == NULL) { |
077 | return -1; |
078 | } |
079 |
080 | /* Open the output file. */ |
081 | if ((output_file = fopen (pszBmpFile, WRITE_BINARY)) == NULL) { |
082 | return -1; |
083 | } |
084 |
085 | /* Specify data source for decompression */ |
086 | jpeg_stdio_src(&cinfo, input_file); |
087 |
088 | /* Read file header, set default decompression parameters */ |
089 | ( void ) jpeg_read_header(&cinfo, TRUE); |
090 |
091 | /* Adjust default decompression parameters by re-parsing the options */ |
092 | //file_index = parse_switches(&cinfo, argc, argv, 0, TRUE); |
093 |
094 | /* Initialize the output module now to let it override any crucial |
095 | * option settings (for instance, GIF wants to force color quantization). |
096 | */ |
097 | dest_mgr = jinit_write_bmp(&cinfo, FALSE); |
098 | dest_mgr->output_file = output_file; |
099 |
100 | /* Start decompressor */ |
101 | ( void ) jpeg_start_decompress(&cinfo); |
102 |
103 | /* Write output file header */ |
104 | (*dest_mgr->start_output) (&cinfo, dest_mgr); |
105 |
106 | /* Process data */ |
107 | while (cinfo.output_scanline < cinfo.output_height) { |
108 | num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer, |
109 | dest_mgr->buffer_height); |
110 | (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines); |
111 | } |
112 |
113 | /* Finish decompression and release memory. |
114 | * I must do it in this order because output module has allocated memory |
115 | * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory. |
116 | */ |
117 | (*dest_mgr->finish_output) (&cinfo, dest_mgr); |
118 | ( void ) jpeg_finish_decompress(&cinfo); |
119 | jpeg_destroy_decompress(&cinfo); |
120 |
121 | /* Close files, if we opened them */ |
122 | fclose (input_file); |
123 | fclose (output_file); |
124 |
125 | /* All done. */ |
126 | return jerr.num_warnings ? -1 : 0; |
127 | } |
[예제 : ce.sharif.edu/~haghshenas/files/c/jpg2bmp.c]
[공식 : http://www.ijg.org/]
'Linux' 카테고리의 다른 글
Gedit에 ctags 확장기능 추가하기 - Plugins (0) | 2009.05.06 |
---|---|
Gedit 옵션을 살펴보자! (0) | 2009.05.06 |
convert(1) - convert between image formats as well as resize an image (0) | 2009.04.28 |
addr2line을 이용한 Fixing up unaligned userspace access 추적 (0) | 2009.04.24 |
Fixing up unaligned userspace access (0) | 2009.04.24 |