diff --git a/rawimage.cpp b/rawimage.cpp index 0b66fe6..e5cffc2 100644 --- a/rawimage.cpp +++ b/rawimage.cpp @@ -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(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(new uint8_t[THUMB_SIZE * THUMB_SIZE * 4 * sizeof(uint16_t)]); + std::unique_ptr outptr = std::make_unique(THUMB_SIZE * THUMB_SIZE * 4 * sizeof(uint16_t)); + uint16_t *out = reinterpret_cast(outptr.get()); auto loop = [&](uint16_t *out, auto *in, auto scale) { @@ -341,12 +342,11 @@ void RawImage::convertToThumbnail() loop(out, reinterpret_cast(m_pixels.get()), 65535.0); break; default: - qDebug() << "Should not happend"; - delete [] out; + qWarning() << "FLOAT64 should not happend"; return; } - m_pixels.reset(reinterpret_cast(out)); + m_pixels = std::move(outptr); m_width = THUMB_SIZE; m_height = THUMB_SIZE; m_ch = 4; diff --git a/rawimage.h b/rawimage.h index d88c0b0..ca2f4ba 100644 --- a/rawimage.h +++ b/rawimage.h @@ -58,8 +58,8 @@ protected: double m_max[4] = {0.0}; double m_mad[4] = {0.0}; }; - std::unique_ptr m_pixels; - std::unique_ptr m_original; + std::unique_ptr m_pixels; + std::unique_ptr m_original; uint32_t m_width = 0; uint32_t m_height = 0; uint32_t m_channels = 0;