r13910 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 05:55:59 CEST 2009


Revision: 13910
Author: jghali
Date: 2009-08-24T22:16:33.913443Z
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  /branches/Version135/Scribus/scribus/pdflib_core.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 13909)
+++ scribus/pdflib_core.cpp	(revision 13910)
@@ -6405,12 +6405,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;
 		}
@@ -6526,12 +6529,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