1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #26211 from Kumataro:fix26207

imgcodecs: implement imencodemulti() #26211

Close #26207
### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Kumataro
2024-10-18 20:44:55 +09:00
committed by GitHub
parent 3919f33e21
commit 35dbf32227
6 changed files with 199 additions and 46 deletions
+22 -16
View File
@@ -171,7 +171,7 @@ public:
{
n = size - pos;
}
memcpy(buffer, buf.ptr() + pos, n);
std::memcpy(buffer, buf.ptr() + pos, n);
helper->m_buf_pos += n;
return n;
}
@@ -848,9 +848,9 @@ bool TiffDecoder::readData( Mat& img )
switch ( convert_flag )
{
case MAKE_FLAG( 1, 1 ): // GRAY to GRAY
memcpy( (void*) img_line_buffer,
(void*) bstart,
tile_width * sizeof(uchar) );
std::memcpy( (void*) img_line_buffer,
(void*) bstart,
tile_width * sizeof(uchar) );
break;
case MAKE_FLAG( 1, 3 ): // GRAY to BGR
@@ -867,9 +867,9 @@ bool TiffDecoder::readData( Mat& img )
case MAKE_FLAG( 3, 3 ): // RGB to BGR
if (m_use_rgb)
memcpy( (void*) img_line_buffer,
(void*) bstart,
tile_width * sizeof(uchar) );
std::memcpy( (void*) img_line_buffer,
(void*) bstart,
tile_width * sizeof(uchar) );
else
icvCvt_BGR2RGB_8u_C3R( bstart, 0,
img_line_buffer, 0,
@@ -979,7 +979,7 @@ bool TiffDecoder::readData( Mat& img )
{
CV_CheckEQ(wanted_channels, 3, "");
if (m_use_rgb)
memcpy(buffer16, img.ptr<ushort>(img_y + i, x), tile_width * sizeof(ushort));
std::memcpy(buffer16, img.ptr<ushort>(img_y + i, x), tile_width * sizeof(ushort));
else
icvCvt_RGB2BGR_16u_C3R(buffer16, 0,
img.ptr<ushort>(img_y + i, x), 0,
@@ -1011,9 +1011,9 @@ bool TiffDecoder::readData( Mat& img )
CV_CheckEQ(wanted_channels, 1, "");
if( ncn == 1 )
{
memcpy(img.ptr<ushort>(img_y + i, x),
buffer16,
tile_width*sizeof(ushort));
std::memcpy(img.ptr<ushort>(img_y + i, x),
buffer16,
tile_width*sizeof(ushort));
}
else
{
@@ -1118,10 +1118,16 @@ public:
/*map=*/0, /*unmap=*/0 );
}
static tmsize_t read( thandle_t /*handle*/, void* /*buffer*/, tmsize_t /*n*/ )
static tmsize_t read( thandle_t handle, void* buffer, tmsize_t n )
{
// Not used for encoding.
return 0;
// Used for imencodemulti() to stores multi-images.
TiffEncoderBufHelper *helper = reinterpret_cast<TiffEncoderBufHelper*>(handle);
size_t begin = (size_t)helper->m_buf_pos;
size_t end = begin + n;
CV_CheckGT( helper->m_buf->size(), end , "do not be over-run buffer");
std::memcpy(buffer, &(*helper->m_buf)[begin], n);
helper->m_buf_pos = end;
return n;
}
static tmsize_t write( thandle_t handle, void* buffer, tmsize_t n )
@@ -1133,7 +1139,7 @@ public:
{
helper->m_buf->resize(end);
}
memcpy(&(*helper->m_buf)[begin], buffer, n);
std::memcpy(&(*helper->m_buf)[begin], buffer, n);
helper->m_buf_pos = end;
return n;
}
@@ -1350,7 +1356,7 @@ bool TiffEncoder::writeLibTiff( const std::vector<Mat>& img_vec, const std::vect
{
case 1:
{
memcpy(buffer, img.ptr(y), scanlineSize);
std::memcpy(buffer, img.ptr(y), scanlineSize);
break;
}