+ _target_size = target_size;
+ _reduce = reduce;
+
+ return reduce;
+}
+
+pair<shared_ptr<Image>, int>
+J2KImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size> target_size) const
+{
+ int const reduce = prepare (target_size);
+
+ shared_ptr<Image> image (new Image (_pixel_format, _decompressed->size(), true));
+
+ /* 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;
+
+ int p = 0;
+ for (int y = 0; y < _decompressed->size().height; ++y) {
+ uint16_t* q = (uint16_t *) (image->data()[0] + y * image->stride()[0]);
+ for (int x = 0; x < width; ++x) {
+ for (int c = 0; c < 3; ++c) {
+ *q++ = _decompressed->data(c)[p] << 4;
+ }
+ ++p;
+ }
+ }
+
+ return make_pair (image, reduce);