Skip to content

Commit

Permalink
Use QImageReader so images are loaded in correct orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed Jul 6, 2022
1 parent 8ea5476 commit 95ef563
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/printerworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ try {
}
else if(targetFormat == Mimer::RBMP)
{
QImage inImage;
QImageReader reader(filename);
reader.setAutoTransform(true);
QImage inImage = reader.read();
QBuffer buf;
if(!inImage.load(filename))

if(inImage.isNull())
{
qDebug() << "failed to load";
throw ConvertFailedException(tr("Failed to load image"));
}

// TODO: calculate paper width minus margins
// (depends on understanding/parsing custom paper sizes)
int width = 576;
Expand All @@ -147,13 +151,17 @@ try {
}
else
{
QImage inImage;
QImageReader reader(filename);
reader.setAutoTransform(true);
QImage inImage = reader.read();
QBuffer buf;
if(!inImage.load(filename))

if(inImage.isNull())
{
qDebug() << "failed to load";
throw ConvertFailedException(tr("Failed to load image"));
}

buf.open(QIODevice::ReadWrite);
inImage.save(&buf, imageFormat.toStdString().c_str());
buf.seek(0);
Expand Down Expand Up @@ -314,7 +322,11 @@ try {
}
else
{
if(!inImage.load(filename))
QImageReader reader(filename);
reader.setAutoTransform(true);
inImage = reader.read();

if(inImage.isNull())
{
qDebug() << "failed to load";
throw ConvertFailedException(tr("Failed to load image"));
Expand Down

0 comments on commit 95ef563

Please sign in to comment.