Browse Source

fix mat clone with atypical source cstep

tags/20211122
nihuini 4 years ago
parent
commit
6c2cee8186
No known key found for this signature in database GPG Key ID: 98FD8F4EBC3E5DB8
1 changed files with 11 additions and 1 deletions
  1. +11
    -1
      src/mat.cpp

+ 11
- 1
src/mat.cpp View File

@@ -48,7 +48,17 @@ Mat Mat::clone(Allocator* _allocator) const

if (total() > 0)
{
memcpy(m.data, data, total() * elemsize);
if (cstep == m.cstep)
memcpy(m.data, data, total() * elemsize);
else
{
// copy by channel for differnet cstep
size_t size = w * h;
for (int i = 0; i < c; i++)
{
memcpy(m.channel(i), channel(i), size * elemsize);
}
}
}

return m;


Loading…
Cancel
Save