Get rid of some explicit new allocation
This commit is contained in:
+5
-5
@@ -31,7 +31,7 @@ void RawImage::allocate(uint32_t w, uint32_t h, uint32_t ch, DataType type)
|
||||
m_channels = ch;
|
||||
m_ch = ch == 3 ? 4 : ch;
|
||||
m_origType = m_type = type;
|
||||
m_pixels.reset(new PixelType[m_width * m_height * m_ch * typeSize(type)]);
|
||||
m_pixels = std::make_unique<PixelType[]>(m_width * m_height * m_ch * typeSize(type));
|
||||
}
|
||||
|
||||
RawImage::RawImage()
|
||||
@@ -301,7 +301,8 @@ void *RawImage::origData(uint32_t row, uint32_t col) const
|
||||
void RawImage::convertToThumbnail()
|
||||
{
|
||||
m_thumbAspect = (float)width() / height();
|
||||
uint16_t *out = reinterpret_cast<uint16_t*>(new uint8_t[THUMB_SIZE * THUMB_SIZE * 4 * sizeof(uint16_t)]);
|
||||
std::unique_ptr<PixelType[]> outptr = std::make_unique<PixelType[]>(THUMB_SIZE * THUMB_SIZE * 4 * sizeof(uint16_t));
|
||||
uint16_t *out = reinterpret_cast<uint16_t*>(outptr.get());
|
||||
|
||||
auto loop = [&](uint16_t *out, auto *in, auto scale)
|
||||
{
|
||||
@@ -341,12 +342,11 @@ void RawImage::convertToThumbnail()
|
||||
loop(out, reinterpret_cast<float*>(m_pixels.get()), 65535.0);
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Should not happend";
|
||||
delete [] out;
|
||||
qWarning() << "FLOAT64 should not happend";
|
||||
return;
|
||||
}
|
||||
|
||||
m_pixels.reset(reinterpret_cast<uint8_t*>(out));
|
||||
m_pixels = std::move(outptr);
|
||||
m_width = THUMB_SIZE;
|
||||
m_height = THUMB_SIZE;
|
||||
m_ch = 4;
|
||||
|
||||
Reference in New Issue
Block a user