diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index c484214..b246211 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -81,7 +81,8 @@ void ViewArea::setImage( std::shared_ptr frame ) m_nextFrame->fillRGBBuffer(); } - m_image = QImage( m_nextFrame->getRGBBuffer(), + auto rgb_buffer = *m_nextFrame->getRGBBuffer(); + m_image = QImage( rgb_buffer.data(), m_nextFrame->getWidth(), m_nextFrame->getHeight(), QImage::Format_ARGB32 ); @@ -115,7 +116,8 @@ void ViewArea::setFilteredChannel( std::size_t channel ) if( m_nextFrame != nullptr ) { m_nextFrame->fillRGBBuffer( m_filterSingleChannel ); - m_image = QImage( m_nextFrame->getRGBBuffer(), + auto rgb_buffer = *m_nextFrame->getRGBBuffer(); + m_image = QImage( rgb_buffer.data(), m_nextFrame->getWidth(), m_nextFrame->getHeight(), QImage::Format_ARGB32 ); @@ -129,7 +131,8 @@ void ViewArea::clearFilteredChannel() if( m_nextFrame != nullptr ) { m_nextFrame->fillRGBBuffer( m_filterSingleChannel ); - m_image = QImage( m_nextFrame->getRGBBuffer(), + auto rgb_buffer = *m_nextFrame->getRGBBuffer(); + m_image = QImage( rgb_buffer.data(), m_nextFrame->getWidth(), m_nextFrame->getHeight(), QImage::Format_ARGB32 ); diff --git a/lib/CalypFrame.cpp b/lib/CalypFrame.cpp index 227001b..8be5853 100644 --- a/lib/CalypFrame.cpp +++ b/lib/CalypFrame.cpp @@ -97,7 +97,7 @@ auto CalypFrame::findPixelFormat( const std::string_view name ) -> std::optional return {}; } -auto CalypFrame::pelformatColorSpace( ClpPixelFormats idx ) -> int +auto CalypFrame::pelFormatColorSpace( ClpPixelFormats idx ) -> int { return g_CalypPixFmtDescriptorsMap.at( idx ).colorSpace; } @@ -536,13 +536,13 @@ ClpPel*** CalypFrame::getPelBufferYUV() return d->m_pppcInputPel; } -auto CalypFrame::getRGBBuffer() const -> const unsigned char* +auto CalypFrame::getRGBBuffer() const -> std::optional> { - if( d->m_bHasRGBPel ) + if( !d->m_bHasRGBPel ) { - return d->m_pcARGB32.data(); + return std::nullopt; } - return NULL; + return std::span{ d->m_pcARGB32 }; } ClpPel CalypFrame::operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute ) const diff --git a/lib/CalypFrame.h b/lib/CalypFrame.h index 1e38f8c..f3588d2 100644 --- a/lib/CalypFrame.h +++ b/lib/CalypFrame.h @@ -222,7 +222,7 @@ public: static constexpr auto numberOfFormats() -> std::size_t; static auto findPixelFormat( const std::string& name ) -> std::optional; static auto findPixelFormat( const std::string_view name ) -> std::optional; - static auto pelformatColorSpace( ClpPixelFormats idx ) -> int; + static auto pelFormatColorSpace( ClpPixelFormats idx ) -> int; static auto supportedPixelFormatListNames() -> std::map; static auto supportedPixelFormatListNames( int colorSpace ) -> std::map; static auto pixelFormatName( ClpPixelFormats idx ) -> const std::string_view; @@ -416,7 +416,7 @@ public: ClpPel*** getPelBufferYUV() const; ClpPel*** getPelBufferYUV(); - auto getRGBBuffer() const -> const unsigned char*; + auto getRGBBuffer() const -> std::optional>; /** * Get pixel value at coordinates