- if (oj->opj_image()->color_space == CLRSPC_SRGB) {
- /* No XYZ -> RGB conversion necessary; just copy and interleave the values */
+ try {
+ /* XXX: should check that potentially trashing _data here doesn't matter */
+ shared_ptr<dcp::OpenJPEGImage> decompressed = dcp::decompress_j2k (const_cast<uint8_t*>(_data->data()), _data->size(), reduce);
+ _image.reset (new Image (_pixel_format, decompressed->size(), true));
+
+ int const shift = 16 - decompressed->precision (0);
+
+ /* Copy data in whatever format (sRGB or XYZ) into our Image; I'm assuming
+ the data is 12-bit either way.
+ */
+
+ int const width = decompressed->size().width;
+