djpeg.c - vx32 - Local 9vx git repository for patches.
 (HTM) git clone git://r-36.net/vx32
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       djpeg.c (1084B)
       ---
            1 
            2 #include <stdio.h>
            3 #include <stdlib.h>
            4 #include <unistd.h>
            5 #include <stdarg.h>
            6 #include <assert.h>
            7 
            8 #include "cdjpeg.h"
            9 
           10 
           11 void fatal(const char *fmt, ...)
           12 {
           13         va_list ap;
           14         va_start(ap, fmt);
           15         vfprintf(stderr, fmt, ap);
           16         va_end(ap);
           17         fputc('\n', stderr);
           18         exit(2);
           19 }
           20 
           21 
           22 static struct jpeg_decompress_struct cinfo;
           23 static struct jpeg_error_mgr jerr;
           24 
           25 int main(int argc, char **argv)
           26 {
           27         cinfo.err = jpeg_std_error(&jerr);
           28         jpeg_create_decompress(&cinfo);
           29         jpeg_stdio_src(&cinfo, stdin);
           30         (void) jpeg_read_header(&cinfo, TRUE);
           31 
           32         djpeg_dest_ptr dest_mgr = jinit_write_bmp(&cinfo, FALSE);
           33         dest_mgr->output_file = stdout;
           34 
           35         (void) jpeg_start_decompress(&cinfo);
           36         dest_mgr->start_output(&cinfo, dest_mgr);
           37 
           38         /* Process data */
           39         while (cinfo.output_scanline < cinfo.output_height) {
           40                 JDIMENSION num_scanlines = jpeg_read_scanlines(
           41                                 &cinfo, dest_mgr->buffer,
           42                                 dest_mgr->buffer_height);
           43                 dest_mgr->put_pixel_rows(&cinfo, dest_mgr, num_scanlines);
           44         }
           45 
           46         dest_mgr->finish_output(&cinfo, dest_mgr);
           47 
           48         (void) jpeg_finish_decompress(&cinfo);
           49         jpeg_destroy_decompress(&cinfo);
           50 
           51         return 0;
           52 }
           53