1d0
< 
9a9,12
> #define JPG_GRAY  1     /* Gray color space, use /DeviceGray  */
> #define JPG_RGB   3     /* RGB color space, use /DeviceRGB    */
> #define JPG_CMYK  4     /* CMYK color space, use /DeviceCMYK  */
> 
79,89c82
< 
< /* Function jpg_read_image_info opens specified file and reads informations
<  * into JPG_IMAGE_INFO structure.
<  *
<  * Return value: 0 - OK
<  *               1 - Cannot open file for read
<  *               2 - Not JPG file
<  *               3 - Cannot find necessary informations
<  */
< 
< integer read_jpg_info(integer img)
---
> void read_jpg_info(integer img)
94,101c87,92
<     JPG_IMAGE_INFO *image_info = jpg_info(img);
<     jpg_info(img)->file = xfopen(img_name(img), FOPEN_RBIN_MODE);
<     xfseek(image_info->file,0,SEEK_END,cur_file_name);
<     image_info->length=xftell(image_info->file,cur_file_name);
<     xfseek(image_info->file,0,SEEK_SET,cur_file_name);
<     if(read2bytes(image_info->file)!=0xFFD8) {
<         xfclose(image_info->file,cur_file_name); return(2);
<     }
---
>     jpg_ptr(img)->file = xfopen(img_name(img), FOPEN_RBIN_MODE);
>     xfseek(jpg_ptr(img)->file,0,SEEK_END,cur_file_name);
>     jpg_ptr(img)->length=xftell(jpg_ptr(img)->file,cur_file_name);
>     xfseek(jpg_ptr(img)->file,0,SEEK_SET,cur_file_name);
>     if(read2bytes(jpg_ptr(img)->file)!=0xFFD8)
>         pdftex_fail("reading JPEG image failed");
103,106c94,96
<         if(feof(image_info->file) || fgetc(image_info->file)!=0xFF) {
<             xfclose(image_info->file,cur_file_name); return(2);
<         }
<         switch(xgetc(image_info->file)) {
---
>         if(feof(jpg_ptr(img)->file) || fgetc(jpg_ptr(img)->file)!=0xFF)
>             pdftex_fail("reading JPEG image failed");
>         switch(xgetc(jpg_ptr(img)->file)) {
108,115c98,104
<             j=read2bytes(image_info->file);
<             for(i=0;i<5;i++) if(xgetc(image_info->file)!=jpg_id[i]) {
<                 xfclose(image_info->file,cur_file_name); return(2);
<             }
<             (void)read2bytes(image_info->file);
<             units=xgetc(image_info->file);
<             image_info->x_res=read2bytes(image_info->file);
<             image_info->y_res=read2bytes(image_info->file);
---
>             j=read2bytes(jpg_ptr(img)->file);
>             for(i=0;i<5;i++) if(xgetc(jpg_ptr(img)->file)!=jpg_id[i])
>                 pdftex_fail("reading JPEG image failed");
>             (void)read2bytes(jpg_ptr(img)->file);
>             units=xgetc(jpg_ptr(img)->file);
>             img_xres(img) = read2bytes(jpg_ptr(img)->file);
>             img_yres(img)=read2bytes(jpg_ptr(img)->file);
118c107
<                 case 2: image_info->x_res*=2.54; image_info->y_res*=2.54;
---
>                 case 2: img_xres(img)*=2.54; img_yres(img)*=2.54;
120c109
<                 default:image_info->x_res=image_info->y_res=0; break;
---
>                 default:img_xres(img)=img_yres(img)=0; break;
122c111
<             xfseek(image_info->file,j-14,SEEK_CUR,cur_file_name); break;
---
>             xfseek(jpg_ptr(img)->file,j-14,SEEK_CUR,cur_file_name); break;
133c122,123
<         case M_SOF15:xfclose(image_info->file,cur_file_name); return(4);
---
>         case M_SOF15:
>             pdftex_fail("unsupported type of compression");
136,142c126,132
<              (void)read2bytes(image_info->file);    /* read segment length  */
<              image_info->bits_per_component = xgetc(image_info->file);
<              image_info->height             = read2bytes(image_info->file);
<              image_info->width              = read2bytes(image_info->file);
<              image_info->color_space        = xgetc(image_info->file);
<              xfseek(image_info->file,0,SEEK_SET,cur_file_name); 
<              switch (jpg_info(img)->color_space) {
---
>              (void)read2bytes(jpg_ptr(img)->file);    /* read segment length  */
>              jpg_ptr(img)->bits_per_component = xgetc(jpg_ptr(img)->file);
>              img_height(img)       = read2bytes(jpg_ptr(img)->file);
>              img_width(img)        = read2bytes(jpg_ptr(img)->file);
>              jpg_ptr(img)->color_space  = xgetc(jpg_ptr(img)->file);
>              xfseek(jpg_ptr(img)->file,0,SEEK_SET,cur_file_name); 
>              switch (jpg_ptr(img)->color_space) {
144c134
<                      set_img_color_type(img, IMAGE_COLOR_B);
---
>                      img_color(img) = IMAGE_COLOR_B;
147c137
<                      set_img_color_type(img, IMAGE_COLOR_C);
---
>                      img_color(img) = IMAGE_COLOR_C;
150c140
<                      set_img_color_type(img, IMAGE_COLOR_C);
---
>                      img_color(img) = IMAGE_COLOR_C;
154c144
<                              (int)jpg_info(img)->color_space);
---
>                              (int)jpg_ptr(img)->color_space);
156c146
<              return(0);
---
>              return;
170c160
<             xfseek(image_info->file,read2bytes(image_info->file)-2,SEEK_CUR,cur_file_name);
---
>             xfseek(jpg_ptr(img)->file,read2bytes(jpg_ptr(img)->file)-2,SEEK_CUR,cur_file_name);
178a169
>     FILE *f;
181,184c172,175
<                (int)jpg_info(img)->width,
<                (int)jpg_info(img)->height,
<                (int)jpg_info(img)->bits_per_component,
<                (int)jpg_info(img)->length);
---
>                img_width(img),
>                img_height(img),
>                (int)jpg_ptr(img)->bits_per_component,
>                (int)jpg_ptr(img)->length);
186c177
<     switch (jpg_info(img)->color_space) {
---
>     switch (jpg_ptr(img)->color_space) {
198c189
<              (int)jpg_info(img)->color_space);
---
>              (int)jpg_ptr(img)->color_space);
201,202c192,193
<     for (l = jpg_info(img)->length; l >0; l--)
<         pdfout(xgetc(jpg_info(img)->file));
---
>     for (l = jpg_ptr(img)->length, f = jpg_ptr(img)->file; l > 0; l--)
>         pdfout(xgetc(f));
