From 8d103b961932ee608dc9d0c866e92853a4d48194 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 25 Mar 2005 14:08:19 +0000 Subject: Fixed linking problems with libjpeg (wrapped it in ' extern "C" ') --- src/img_encoder.cc | 110 ++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) (limited to 'src/img_encoder.cc') diff --git a/src/img_encoder.cc b/src/img_encoder.cc index e6cfd2a..75801c8 100644 --- a/src/img_encoder.cc +++ b/src/img_encoder.cc @@ -101,59 +101,59 @@ void ImgEncoder::writeJPEGFile(char *filename, int image_height // Number of rows in image ) { - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - - FILE * outfile; // target file - JSAMPROW row_pointer[1]; // pointer to JSAMPLE row[s] - int row_stride; // physical row width in image buffer - - // Step 1: allocate and initialize JPEG compression object - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - - // Step 2: specify data destination (eg, a file) - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - // Step 3: set parameters for compression - cinfo.image_width = image_width; // image width and height, in pixels - cinfo.image_height = image_height; - cinfo.input_components = 3; // # of color components per pixel -/* -typedef enum { - JCS_UNKNOWN, // error/unspecified - JCS_GRAYSCALE, // monochrome - JCS_RGB, // red/green/blue - JCS_YCbCr, // Y/Cb/Cr (also known as YUV) - JCS_CMYK, // C/M/Y/K - JCS_YCCK // Y/Cb/Cr/K -} J_COLOR_SPACE; -*/ - cinfo.in_color_space = JCS_RGB; // colorspace of input image - - jpeg_set_defaults(&cinfo); - - jpeg_set_quality(&cinfo, quality, TRUE); // limit to baseline-JPEG values - - // Step 4: Start compressor - jpeg_start_compress(&cinfo, TRUE); - - // Step 5: while (scan lines remain to be written) - row_stride = image_width * 3; // JSAMPLEs per row in image_buffer - - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - // Step 6: Finish compression - jpeg_finish_compress(&cinfo); - fclose(outfile); - - // Step 7: release JPEG compression object - jpeg_destroy_compress(&cinfo); + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + + FILE * outfile; // target file + JSAMPROW row_pointer[1]; // pointer to JSAMPLE row[s] + int row_stride; // physical row width in image buffer + + // Step 1: allocate and initialize JPEG compression object + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + + // Step 2: specify data destination (eg, a file) + if ((outfile = fopen(filename, "wb")) == NULL) { + fprintf(stderr, "can't open %s\n", filename); + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + + // Step 3: set parameters for compression + cinfo.image_width = image_width; // image width and height, in pixels + cinfo.image_height = image_height; + cinfo.input_components = 3; // # of color components per pixel + + //typedef enum { + // JCS_UNKNOWN, // error/unspecified + // JCS_GRAYSCALE, // monochrome + // JCS_RGB, // red/green/blue + // JCS_YCbCr, // Y/Cb/Cr (also known as YUV) + // JCS_CMYK, // C/M/Y/K + // JCS_YCCK // Y/Cb/Cr/K + //} J_COLOR_SPACE; + + cinfo.in_color_space = JCS_RGB; // colorspace of input image + + jpeg_set_defaults(&cinfo); + + jpeg_set_quality(&cinfo, quality, TRUE); // limit to baseline-JPEG values + + // Step 4: Start compressor + jpeg_start_compress(&cinfo, TRUE); + + // Step 5: while (scan lines remain to be written) + row_stride = image_width * 3; // JSAMPLEs per row in image_buffer + + while (cinfo.next_scanline < cinfo.image_height) { + row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + + // Step 6: Finish compression + jpeg_finish_compress(&cinfo); + fclose(outfile); + + // Step 7: release JPEG compression object + jpeg_destroy_compress(&cinfo); } -- cgit v1.2.3