r19384 by craig - #12558: Apply patch to limit image size on import to page

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 29 19:04:16 UTC 2014


Author: craig
Date: Tue Jul 29 19:04:15 2014
New Revision: 19384

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19384
Log:
#12558: Apply patch to limit image size on import to page

Modified:
    trunk/Scribus/scribus/scribusview.cpp

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19384&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Jul 29 19:04:15 2014
@@ -845,8 +845,30 @@
 			PageItem *b = Doc->Items->at(z);
 			b->LayerID = Doc->activeLayer();
 			Doc->loadPict(url.toLocalFile(), b);
-			b->setWidth(static_cast<double>(b->OrigW * 72.0 / b->pixm.imgInfo.xres));
-			b->setHeight(static_cast<double>(b->OrigH * 72.0 / b->pixm.imgInfo.yres));
+
+			double iw = static_cast<double>(b->OrigW * 72.0 / b->pixm.imgInfo.xres);
+			double ih = static_cast<double>(b->OrigH * 72.0 / b->pixm.imgInfo.yres);
+			if (iw > ih)
+			{
+				double pw = Doc->currentPage()->width();
+				if (iw > pw)
+				{
+					ih = pw * (ih / iw);
+					iw = pw;
+				}
+			}
+			else
+			{
+				double ph = Doc->currentPage()->height();
+				if (ih > ph)
+				{
+					iw = ph * (iw / ih);
+					ih = ph;
+				}
+			}
+
+			b->setWidth(iw);
+			b->setHeight(ih);
 			b->OldB2 = b->width();
 			b->OldH2 = b->height();
 			b->updateClip();




More information about the scribus-commit mailing list