Skip to content

Commit

Permalink
Bug fix: setting extension before loading image from buffer
Browse files Browse the repository at this point in the history
Loading image from the buffer needs the expected extension to be set in advance. Otherwise, image loading does not know the format and runs into problems.
  • Loading branch information
sterne-jaeger committed May 10, 2024
1 parent aff30fb commit 622d0d1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kstars/ekos/align/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3086,8 +3086,8 @@ bool Align::loadAndSlew(const QByteArray &image, const QString &extension)
m_ImageData.clear();
QSharedPointer<FITSData> data;
data.reset(new FITSData(), &QObject::deleteLater);
data->loadFromBuffer(image);
data->setExtension(extension);
data->loadFromBuffer(image);
m_AlignView->loadData(data);
startSolving();
return true;
Expand Down
3 changes: 1 addition & 2 deletions kstars/ekos/auxiliary/darklibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,10 @@ void DarkLibrary::updateProperty(INDI::Property prop)
return;

auto bp = prop.getBLOB()->at(0);
m_CurrentDarkFrame->setExtension(QString(bp->getFormat()));
QByteArray buffer = QByteArray::fromRawData(reinterpret_cast<char *>(bp->getBlob()), bp->getSize());
if (!m_CurrentDarkFrame->loadFromBuffer(buffer))
{
QString ext(QString(bp->getFormat()));
m_CurrentDarkFrame->setExtension(ext);
m_FileLabel->setText(i18n("Failed to process dark data."));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion kstars/ekos/guide/externalguide/phd2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,8 +1090,8 @@ void PHD2::processStarImage(const QJsonObject &jsonStarFrame)
QSharedPointer<FITSData> fdata;
QByteArray buffer = QByteArray::fromRawData(reinterpret_cast<char *>(fits_buffer), fits_buffer_size);
fdata.reset(new FITSData(), &QObject::deleteLater);
fdata->loadFromBuffer(buffer);
fdata->setExtension(QString("fits"));
fdata->loadFromBuffer(buffer);
free(fits_buffer);
m_GuideFrame->loadData(fdata);

Expand Down

0 comments on commit 622d0d1

Please sign in to comment.