- case J2K_CFMT:
- {
- /* JPEG-2000 codestream */
-
- /* get a decoder handle */
- dinfo = opj_create_decompress(CODEC_J2K);
-
- /* catch events using our callbacks and give a local context */
- opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);
-
- /* setup the decoder decoding parameters using user parameters */
- opj_setup_decoder(dinfo, ¶meters);
-
- /* open a byte stream */
- cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
-
- /* decode the stream and fill the image structure */
- if (*indexfilename) // If need to extract codestream information
- image = opj_decode_with_info(dinfo, cio, &cstr_info);
- else
- image = opj_decode(dinfo, cio);
- if(!image) {
- fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
- opj_destroy_decompress(dinfo);
- opj_cio_close(cio);
- return 1;
- }
- /* dump image */
- j2k_dump_image(stdout, image);