Lines 92-102
Link Here
|
92 |
int *real_width,int *real_height) |
92 |
int *real_width,int *real_height) |
93 |
{ |
93 |
{ |
94 |
static FILE *in; |
94 |
static FILE *in; |
|
|
95 |
static int cmyk; |
95 |
struct my_error_mgr jerr; |
96 |
struct my_error_mgr jerr; |
96 |
int row_stride; /* physical row width in output buffer */ |
97 |
int row_stride; /* physical row width in output buffer */ |
97 |
int tmp,f; |
98 |
int tmp,f; |
98 |
unsigned char *ptr; |
99 |
unsigned char *ptr,*ptr2; |
99 |
|
100 |
|
|
|
101 |
cmyk=0; |
100 |
use_errmsg=0; |
102 |
use_errmsg=0; |
101 |
theimage=NULL; |
103 |
theimage=NULL; |
102 |
howfar=howfarfunc; |
104 |
howfar=howfarfunc; |
Lines 161-166
Link Here
|
161 |
pal[f]=pal[256+f]=pal[512+f]=f; |
163 |
pal[f]=pal[256+f]=pal[512+f]=f; |
162 |
} |
164 |
} |
163 |
|
165 |
|
|
|
166 |
if(cinfo.jpeg_color_space==JCS_CMYK) |
167 |
cmyk=1; |
168 |
|
169 |
if(cinfo.jpeg_color_space==JCS_YCCK) |
170 |
{ |
171 |
cmyk=1; |
172 |
cinfo.out_color_space=JCS_CMYK; |
173 |
} |
174 |
|
164 |
width=cinfo.image_width; |
175 |
width=cinfo.image_width; |
165 |
height=cinfo.image_height; |
176 |
height=cinfo.image_height; |
166 |
|
177 |
|
Lines 191-197
Link Here
|
191 |
} |
202 |
} |
192 |
|
203 |
|
193 |
if(WH_BAD(width,height) || |
204 |
if(WH_BAD(width,height) || |
194 |
(theimage=(byte *)malloc(pixelsize*width*height))==NULL) |
205 |
(theimage=(byte *)malloc(pixelsize*width*(height+cmyk)))==NULL) |
195 |
{ |
206 |
{ |
196 |
jpegerr("Out of memory"); /* XXX misleading if width/height are bad */ |
207 |
jpegerr("Out of memory"); /* XXX misleading if width/height are bad */ |
197 |
longjmp(jerr.setjmp_buffer,1); |
208 |
longjmp(jerr.setjmp_buffer,1); |
Lines 222-228
Link Here
|
222 |
while(cinfo.output_scanline<height) |
233 |
while(cinfo.output_scanline<height) |
223 |
{ |
234 |
{ |
224 |
jpeg_read_scanlines(&cinfo,&ptr,1); |
235 |
jpeg_read_scanlines(&cinfo,&ptr,1); |
225 |
for(f=0;f<width;f++) { tmp=*ptr; *ptr=ptr[2]; ptr[2]=tmp; ptr+=3; } |
236 |
if(!cmyk) |
|
|
237 |
for(f=0;f<width;f++) { tmp=*ptr; *ptr=ptr[2]; ptr[2]=tmp; ptr+=3; } |
238 |
else |
239 |
{ |
240 |
ptr2=ptr; |
241 |
for(f=0;f<width;f++,ptr+=3,ptr2+=4) |
242 |
{ |
243 |
tmp=ptr2[3]; |
244 |
ptr[0]=(tmp*ptr2[2])/255; |
245 |
ptr[1]=(tmp*ptr2[1])/255; |
246 |
ptr[2]=(tmp*ptr2[0])/255; |
247 |
} |
248 |
} |
249 |
|
226 |
if(howfar!=NULL) howfar(cinfo.output_scanline,height); |
250 |
if(howfar!=NULL) howfar(cinfo.output_scanline,height); |
227 |
} |
251 |
} |
228 |
|
252 |
|