Click to See Complete Forum and Search --> : libjpeg problem


gung
December 27th, 2008, 11:39 AM
I've just installed the ijg jpeg library and wanted to give it a try. But for some reasons it crashes.
Here is my code:

/*
* test.cpp
*
* Created on: 10.12.2008
*
*/

#include<iostream>
#include<stdlib.h>

using namespace std;

#include <jconfig.h>
#include <jerror.h>
#include <jmorecfg.h>
#include <jpeglib.h>

int main()
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;

JSAMPLE image[800];
int i;
for(i=0;i<800;i++)
{
//image[i]=char(i%50);
}

cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);

cinfo.image_width = 800; /* image width and height, in pixels */
cinfo.image_height = 600;
cinfo.input_components = 1; /* # of color components per pixel */
cinfo.in_color_space = JCS_GRAYSCALE; /* colorspace of input image */

jpeg_set_defaults(&cinfo);

jpeg_start_compress(&cinfo, TRUE);

JSAMPROW row_pointer[1];
int row_stride;
row_stride = 800;

while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = & image[0];
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}

jpeg_finish_compress(&cinfo);

return 0;
}

By debugging, I found out, that it crashes at "jpeg_start_compress(&cinfo, TRUE);".

I'm using mingw with eclipse ganimede under windows vista. I linked (-l) jpeg, libgsl, libgslcblas and libjpeg. I can't link jpeg-bcc.lib. When I try to do so, I get an error:

GnuWin32\lib/jpeg-bcc.lib: file not recognized: File format not recognized
collect2: ld returned 1 exit status
Build error occurred, build is stopped

I hope anyone can help me with it.

fred100
December 28th, 2008, 05:08 AM
Don't use libjpeg. Useless on Win32 (JPEG is native)

gung
December 28th, 2008, 07:49 AM
Don't use libjpeg. Useless on Win32 (JPEG is native)

Do you know a tutorial how to use it?

ovidiucucu
December 28th, 2008, 02:14 PM
Don't use libjpeg. Useless on Win32 (JPEG is native)
Again, native of who? [ http://www.codeguru.com/forum/showpost.php?p=1796108&postcount=4 ]

carl666
December 29th, 2008, 11:14 AM
Do you know a tutorial how to use it?

You can ask on Advanced Win32 api newsgroup :
news://comp.os.ms-windows.programmer.win32
where all native methods to read any file format have been explained
(even undocumented ones...)