Problem in converting Jpeg to DIB, Iam using the same code for Jpeg RGB(Jpeg_color_space=JCS_RGB) and Grayscale Images(JCS_GRAYSCALE). this code works correctly for Jpeg RGB Images when i create DIB for 24 bit. But for Jpeg Grayscale(JCS_GRAYSCALE) images, when i am converting to DIB I get a Black color space next to image,but the original image does'nt contain any black space.
Please help me to solve this problem using the same code. I dont Know where the problem occurs.
following is the code i use for converting jpeg to DIB.
//Function to convert jpeg to dib.
int convert_jpeg_to_dib(const char * filename)
{
struct jpeg_decompress_struct cinfo;
unsigned char * buffer;
int result = 0;
struct my_error_mgr jerr;
FILE * infile; /* source file */
int row_stride; /* physical row width in output buffer */
if ((infile = fopen(filename, "rb")) == NULL)
{
fprintf(stderr, "can't open %s\n", filename);
return result;
}