1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

APT demod: fixed image format issue

This commit is contained in:
f4exb 2021-04-23 17:12:26 +02:00
parent 8d8a79e507
commit 274cf14afd

View File

@ -140,18 +140,32 @@ bool APTDemodGUI::handleMessage(const Message& message)
if (m_settings.m_flip) if (m_settings.m_flip)
{ {
QImage::Format imageFormat = m_image.format(); // save format
m_pixmap.convertFromImage(m_image); m_pixmap.convertFromImage(m_image);
m_pixmap.scroll(0, 1, 0, 0, m_image.width(), m_image.height()-1); // scroll down 1 line m_pixmap.scroll(0, 1, 0, 0, m_image.width(), m_image.height()-1); // scroll down 1 line
m_image = m_pixmap.toImage(); m_image = m_pixmap.toImage();
m_image.convertTo(imageFormat); // restore format
} }
} }
int len = std::min(m_image.width(), lineMsg.getSize()); int len = std::min(m_image.width(), lineMsg.getSize());
std::copy( uchar *p = m_image.scanLine(m_settings.m_flip ? 0 : m_image.height()-1);
lineMsg.getLine(),
lineMsg.getLine() + len, // imageDepth == 8 ? QImage::Format_Grayscale8 : QImage::Format_RGB888
m_image.scanLine(m_settings.m_flip ? 0 : m_image.height()-1)
); if (m_image.format() == QImage::Format_Grayscale8)
{
std::copy( lineMsg.getLine(), lineMsg.getLine() + len, p);
}
else if (m_image.format() == QImage::Format_RGB888)
{
for (int i = 0; i < len; i++)
{
uchar q = lineMsg.getLine()[i];
std::fill(&p[3*i], &p[3*i+3], q); // RGB888
}
}
m_pixmap.convertFromImage(m_image); m_pixmap.convertFromImage(m_image);
ui->image->setPixmap(m_pixmap); ui->image->setPixmap(m_pixmap);