149{
154
155 if (
This->cinfo_initialized)
157
159
162
164
166
169
171
173
175
177
178 This->source_mgr.bytes_in_buffer = 0;
184
185 This->cinfo.src = &
This->source_mgr;
186
188
190 WARN(
"Jpeg image in stream has bad format, read header returned %d.\n",
ret);
192 }
193
194 switch (
This->cinfo.jpeg_color_space)
195 {
199 This->frame.pixel_format = GUID_WICPixelFormat8bppGray;
200 break;
204 This->frame.bpp = 24;
205 This->frame.pixel_format = GUID_WICPixelFormat24bppBGR;
206 break;
210 This->frame.bpp = 32;
211 This->frame.pixel_format = GUID_WICPixelFormat32bppCMYK;
212 break;
213 default:
214 ERR(
"Unknown JPEG color space %i\n",
This->cinfo.jpeg_color_space);
216 }
217
218 if (!jpeg_start_decompress(&
This->cinfo))
219 {
220 ERR(
"jpeg_start_decompress failed\n");
222 }
223
224 This->frame.width =
This->cinfo.output_width;
225 This->frame.height =
This->cinfo.output_height;
226
227 switch (
This->cinfo.density_unit)
228 {
229 case 2:
230 This->frame.dpix =
This->cinfo.X_density * 2.54;
231 This->frame.dpiy =
This->cinfo.Y_density * 2.54;
232 break;
233
234 case 1:
235 This->frame.dpix =
This->cinfo.X_density;
236 This->frame.dpiy =
This->cinfo.Y_density;
237 break;
238
239 case 0:
240 default:
241 This->frame.dpix =
This->frame.dpiy = 96.0;
242 break;
243 }
244
245 This->frame.num_color_contexts = 0;
246 This->frame.num_colors = 0;
247
248 This->stride = (
This->frame.bpp *
This->cinfo.output_width + 7) / 8;
249 data_size =
This->stride *
This->cinfo.output_height;
250
251 if (data_size /
This->stride <
This->cinfo.output_height)
252
254
256 if (!
This->image_data)
258
259 while (
This->cinfo.output_scanline <
This->cinfo.output_height)
260 {
261 UINT first_scanline =
This->cinfo.output_scanline;
265
266 max_rows =
min(
This->cinfo.output_height-first_scanline, 4);
267 for (
i=0;
i<max_rows;
i++)
268 out_rows[
i] =
This->image_data +
This->stride * (first_scanline+
i);
269
272 {
273 ERR(
"read_scanlines failed\n");
275 }
276 }
277
278 if (
This->frame.bpp == 24)
279 {
280
282 This->cinfo.output_width,
This->cinfo.output_height,
284 }
285
286 if (
This->cinfo.out_color_space ==
JCS_CMYK &&
This->cinfo.saw_Adobe_marker)
287 {
288
289 for (
i=0;
i<data_size;
i++)
290 This->image_data[
i] ^= 0xff;
291 }
292
299}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
jpeg_std_error(struct jpeg_error_mgr *err)
static void source_mgr_term_source(j_decompress_ptr cinfo)
static boolean source_mgr_fill_input_buffer(j_decompress_ptr cinfo)
static void emit_message_fn(j_common_ptr cinfo, int msg_level)
static void error_exit_fn(j_common_ptr cinfo)
static void source_mgr_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
static void source_mgr_init_source(j_decompress_ptr cinfo)
@ WICBitmapDecoderCapabilityCanDecodeSomeImages
@ WICBitmapDecoderCapabilityCanEnumerateMetadata
@ WICBitmapDecoderCapabilityCanDecodeAllImages
HRESULT CDECL stream_seek(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG *new_position)
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
#define DECODER_FLAGS_UNSUPPORTED_COLOR_CONTEXT
#define WINCODEC_ERR_WRONGSTATE