diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-11-07 15:57:12 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-11-07 15:57:12 +0000 |
| commit | 77d3d8217a55e100a45fb65d489875c6a9b1b620 (patch) | |
| tree | 7daac66e4a99e73028529139409d4f9ff2eb58b7 /src/openjpeg_image.cc | |
| parent | 4e15f606b7c268727b34603dabd1f2dbe368fbef (diff) | |
Add copy constructor for OpenJPEGImage.
Diffstat (limited to 'src/openjpeg_image.cc')
| -rw-r--r-- | src/openjpeg_image.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/openjpeg_image.cc b/src/openjpeg_image.cc index 32d1da3f..401b6aa1 100644 --- a/src/openjpeg_image.cc +++ b/src/openjpeg_image.cc @@ -53,6 +53,28 @@ OpenJPEGImage::OpenJPEGImage (opj_image_t* image) DCP_ASSERT (_opj_image->numcomps == 3); } +OpenJPEGImage::OpenJPEGImage (OpenJPEGImage const & other) +{ + _opj_image = reinterpret_cast<opj_image_t*> (malloc (sizeof (opj_image_t))); + DCP_ASSERT (_opj_image); + memcpy (_opj_image, other._opj_image, sizeof (opj_image_t)); + + int const data_size = _opj_image->x1 * _opj_image->y1 * 4; + + _opj_image->comps = reinterpret_cast<opj_image_comp_t*> (malloc (_opj_image->numcomps * sizeof (opj_image_comp_t))); + DCP_ASSERT (_opj_image->comps); + memcpy (_opj_image->comps, other._opj_image->comps, _opj_image->numcomps * sizeof (opj_image_comp_t)); + for (unsigned int i = 0; i < _opj_image->numcomps; ++i) { + _opj_image->comps[i].data = reinterpret_cast<OPJ_INT32*> (malloc (data_size)); + DCP_ASSERT (_opj_image->comps[i].data); + memcpy (_opj_image->comps[i].data, other._opj_image->comps[i].data, data_size); + } + + _opj_image->icc_profile_buf = reinterpret_cast<OPJ_BYTE*> (malloc (_opj_image->icc_profile_len)); + DCP_ASSERT (_opj_image->icc_profile_buf); + memcpy (_opj_image->icc_profile_buf, other._opj_image->icc_profile_buf, _opj_image->icc_profile_len); +} + /** Construct a new OpenJPEGImage with undefined contents. * @param size Size for the frame in pixels. */ |
