r13911 by jghali - #8380 : "Embed EPS/PDF Files" option produces slightly wrong scale/position when file dimensions are not an integral number of points

scribus-commit scribus-commit at lists.scribus.net
Wed Aug 26 06:08:04 CEST 2009


Revision: 13911
Author: jghali
Date: 2009-08-24T22:17:07.880876Z
Commit message: #8380 : "Embed EPS/PDF Files" option produces slightly wrong scale/position when file dimensions are not an integral number of points

Changeset: 
M  /trunk/Scribus/scribus/pdflib_core.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 13910)
+++ scribus/pdflib_core.cpp	(revision 13911)
@@ -6539,12 +6539,15 @@
 			Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj;
 			imgInfo.ResNum = ResCount;
 			ResCount++;
-			imgInfo.Width = pagesize.GetWidth();
-			imgInfo.Height = pagesize.GetHeight();
-			imgInfo.xa = sx;
-			imgInfo.ya = sy;
-			imgInfo.sxa = sx;
-			imgInfo.sya = sy;
+			// Avoid a divide-by-zero if width/height are less than 1 point:
+			imgInfo.Width  = qMax(1, (int) pagesize.GetWidth());
+			imgInfo.Height = qMax(1, (int) pagesize.GetHeight());
+			imgInfo.xa  = sx * pagesize.GetWidth()/imgInfo.Width;
+			imgInfo.ya  = sy * pagesize.GetHeight()/imgInfo.Height;
+			// Width/Height are integers and may not exactly equal pagesize.GetWidth()/
+			// pagesize.GetHeight(). Adjust scale factor to compensate for the difference.
+			imgInfo.sxa = sx * pagesize.GetWidth()/imgInfo.Width;
+			imgInfo.sya = sy * pagesize.GetHeight()/imgInfo.Height;
 			
 			return true;
 		}
@@ -6660,12 +6663,15 @@
 			Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = xObj;
 			imgInfo.ResNum = ResCount;
 			ResCount++;
-			imgInfo.Width = pagesize.GetWidth();
-			imgInfo.Height = pagesize.GetHeight();
-			imgInfo.xa = sx;
-			imgInfo.ya = sy;
-			imgInfo.sxa = sx;
-			imgInfo.sya = sy;
+			// Avoid a divide-by-zero if width/height are less than 1 point:
+			imgInfo.Width  = qMax(1, (int) pagesize.GetWidth());
+			imgInfo.Height = qMax(1, (int) pagesize.GetHeight());
+			imgInfo.xa  = sx * pagesize.GetWidth()/imgInfo.Width;
+			imgInfo.ya  = sy * pagesize.GetHeight()/imgInfo.Height;
+			// Width/Height are integers and may not exactly equal pagesize.GetWidth()/
+			// pagesize.GetHeight(). Adjust scale factor to compensate for the difference.
+			imgInfo.sxa = sx * pagesize.GetWidth()/imgInfo.Width;
+			imgInfo.sya = sy * pagesize.GetHeight()/imgInfo.Height;
 			
 			return true;
 		}




More information about the scribus-commit mailing list