Use std::span to give access to RGB buffer
This commit is contained in:
3 files changed
+13
-10
No files matched your search
+6
-3
@@ -81,7 +81,8 @@ void ViewArea::setImage( std::shared_ptr<CalypFrame> 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 );
|
||||
|
||||
+5
-5
@@ -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<std::span<const std::uint8_t>>
|
||||
{
|
||||
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
|
||||
|
||||
+2
-2
@@ -222,7 +222,7 @@ public:
|
||||
static constexpr auto numberOfFormats() -> std::size_t;
|
||||
static auto findPixelFormat( const std::string& name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto findPixelFormat( const std::string_view name ) -> std::optional<ClpPixelFormats>;
|
||||
static auto pelformatColorSpace( ClpPixelFormats idx ) -> int;
|
||||
static auto pelFormatColorSpace( ClpPixelFormats idx ) -> int;
|
||||
static auto supportedPixelFormatListNames() -> std::map<ClpPixelFormats, std::string_view>;
|
||||
static auto supportedPixelFormatListNames( int colorSpace ) -> std::map<ClpPixelFormats, std::string_view>;
|
||||
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<std::span<const std::uint8_t>>;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
|
||||
Reference in new issue
Block a user