fixed crash in double page mode (with single first or last pages)

This commit is contained in:
Luis Ángel San Martín 2013-07-02 20:34:03 +02:00
parent 8a50379d30
commit bb7c0275b7

View File

@ -399,24 +399,39 @@ void DoublePageRender::run()
if(img2.isNull()) if(img2.isNull())
img2 = QPixmap(img.width(),img.height());*/ img2 = QPixmap(img.width(),img.height());*/
int x,y; if(img.isNull() && !img2.isNull())
{
img = img2;
img2 = QImage();
}
int totalWidth,totalHeight;
//x = img.width()+img2.width(); //x = img.width()+img2.width();
y = qMax(img.height(),img2.height()); totalHeight = qMax(img.height(),img2.height());
//widths fiting the normalized height //widths fiting the normalized height
int width1, width2; int width1, width2;
//altura normalizada //altura normalizada
if(img.height()!=y) if(!img2.isNull())
x = (width1 = ((img.width() * y) / img.height())) + (width2 = img2.width()); {
if(img.height()!=totalHeight)
totalWidth = (width1 = ((img.width() * totalHeight) / img.height())) + (width2 = img2.width());
else
totalWidth = (width1 = img.width()) + (width2 = ((img2.width() * totalHeight) / img2.height()));
}
else else
x = (width1 = img.width()) + (width2 = ((img2.width() * y) / img2.height())); totalWidth = width1 = img.width();
QImage auxImg(x,y,QImage::Format_RGB32);
QImage auxImg(totalWidth,totalHeight,QImage::Format_RGB32);
QPainter painter(&auxImg); QPainter painter(&auxImg);
painter.drawImage(QRect(0,0,width1,y),img); painter.drawImage(QRect(0,0,width1,totalHeight),img);
painter.drawImage(QRect(width1,0,width2,y),img2); if(!img2.isNull())
painter.drawImage(QRect(width1,0,width2,totalHeight),img2);
painter.end(); painter.end();
if(degrees > 0) if(degrees > 0)