55 if(JP2_Source == NULL) {
58 JP2_Stream =
new jp2_family_src();
59 JP2_Stream->open(
p_jp2File.toLatin1().data());
62 JP2_Source =
new jp2_source();
63 if(!JP2_Source->open(JP2_Stream)) {
64 QString msg =
"Unable to open the decoder because the source file ";
65 msg +=
"does not have valid JP2 format content [" +
p_jp2File +
"]";
70 JP2_Source->read_header();
73 JPEG2000_Codestream =
new kdu_codestream();
74 JPEG2000_Codestream->create(JP2_Source);
78 p_numBands = JPEG2000_Codestream->get_num_components(
true);
82 JPEG2000_Codestream->get_dims(0, p_imageDims,
true);
85 p_pixelBits = JPEG2000_Codestream->get_bit_depth(0,
true);
86 p_pixelBytes = (p_pixelBits >> 3) + ((p_pixelBits % 8) ? 1 : 0);
89 QString msg =
"The source file has unsupported pixel type ";
98 unsigned int pixel_bits;
100 for(
unsigned int band = 1; band <
p_numBands; ++band) {
101 JPEG2000_Codestream->get_dims(band, dims,
true);
102 pixel_bits = JPEG2000_Codestream->get_bit_depth(band,
true);
103 signed_data = JPEG2000_Codestream->get_signed(band,
true);
104 if(dims.size.x != p_imageDims.size.x || dims.size.y != p_imageDims.size.y ||
105 dims.pos.x != p_imageDims.pos.x || dims.pos.y != p_imageDims.pos.y ||
106 pixel_bits != p_pixelBits || signed_data !=
p_signedData) {
107 std::string msg =
"The source file does not have bands with matching ";
108 msg +=
"characteristics";
115 p_highestResLevel = JPEG2000_Codestream->get_min_dwt_levels() + 1;
120 p_decompressor.start(*JPEG2000_Codestream);
129 p_decompressor.get_recommended_stripe_heights(MIN_STRIPE_HEIGHT,
130 MAX_STRIPE_HEIGHT, p_stripeHeights, p_maxStripeHeights);
131 for(
unsigned int i = 0; i <
p_numBands; i++) {
132 p_precisions[i] = p_pixelBits;
133 p_stripeHeights[i] = 1;
149 JPEG2000_Codestream->apply_input_restrictions(0, 0, p_resolutionLevel - 1, 0, NULL,
150 KDU_WANT_OUTPUT_COMPONENTS);
152 JPEG2000_Codestream->get_dims(0, p_imageDims,
true);