49 if (jp==NULL || jp->image==NULL || jp->image->comps==NULL)
return;
51 jp->xs = jp->image->x1 - jp->image->x0;
52 jp->ys = jp->image->y1 - jp->image->y0;
54 int fac = (int)jp->image->comps->factor;
55 jp->ws = (jp->xs + (1<<fac) - 1)>>fac;
56 jp->hs = (jp->ys + (1<<fac) - 1)>>fac;
58 jp->col = (int)jp->image->numcomps;
76#if OPENJPEG_VER < JP2K_VER_25
77 int depth = (int)jp->image->comps->bpp;
79 int depth = (int)jp->image->comps->prec;
82 DEBUG_MODE PRINT_MESG(
"JBXL::JPEG2KIMage::setup_image: INFO: xs = %d, ys = %d, col = %d, depth = %d\n", jp->xs, jp->ys, jp->col, depth);
83 if (depth==0 || depth==8) {
89 PRINT_MESG(
"JBXL::JPEG2KIMage::setup_image: unknown color mode: col = %d, depth = %d\n", jp->col, depth);
162 opj_stream_t* stream = NULL;
163 opj_codec_t* codec = NULL;
165 opj_dparameters_t parameters;
166 opj_set_default_decoder_parameters(¶meters);
168#if OPENJPEG_VER < JP2K_VER_21
169 stream = opj_stream_create_default_file_stream(fp, 1);
171 stream = opj_stream_create_default_file_stream(fname, 1);
179 if (format==JP2K_FMT_J2K) {
180 codec = opj_create_decompress(OPJ_CODEC_J2K);
182 else if (format==JP2K_FMT_JP2) {
183 codec = opj_create_decompress(OPJ_CODEC_JP2);
185 else if (format==JP2K_FMT_JPT) {
186 codec = opj_create_decompress(OPJ_CODEC_JPT);
189 PRINT_MESG(
"ERROR: JBXL::readJPEG2KData: unknown file format!\n");
190 opj_stream_destroy(stream);
194 if (!opj_setup_decoder(codec, ¶meters) ){
195 opj_stream_destroy(stream);
196 opj_destroy_codec(codec);
202 if (!opj_decoder_set_strict_mode(codec, OPJ_FALSE)) {
203 opj_stream_destroy(stream);
204 opj_destroy_codec(codec);
217 if (!opj_read_header(stream, codec, &jp.image)){
218 opj_stream_destroy(stream);
219 opj_destroy_codec(codec);
224 if (!opj_set_decode_area(codec, jp.image, 0, 0, 0, 0)){
225 opj_stream_destroy(stream);
226 opj_destroy_codec(codec);
232 if (!(opj_decode(codec, stream, jp.image) && opj_end_decompress(codec, stream))) {
233 opj_destroy_codec(codec);
234 opj_stream_destroy(stream);
242 opj_stream_destroy(stream);
243 opj_destroy_codec(codec);