Sophie

Sophie

distrib > Mandriva > 2007.1 > i586 > by-pkgid > b489161e8179a429b4f3255503fcb3d7 > files > 1

gwenview-1.4.1-5.1mdv2007.1.src.rpm

Index: document.cpp
===================================================================
--- document.cpp	(revisione 626292)
+++ document.cpp	(copia locale)
@@ -411,10 +411,21 @@
 			size.setHeight( int(hImg * printer->resolution()) );
 		} else {
 			/* GV_NOSCALE: no scaling */
-			size = image.size();
+			// try to get the density info so that we can print using original size
+			// known if it is am image from scanner for instance
+			const float INCHESPERMETER = (100. / 2.54);
+			if (image.dotsPerMeterX())
+			{
+				double wImg = double(size.width()) / double(image.dotsPerMeterX()) * INCHESPERMETER;
+				size.setWidth( int(wImg *printer->resolution()) );
+			}
+			if (image.dotsPerMeterY())
+			{
+				double hImg = double(size.height()) / double(image.dotsPerMeterY()) * INCHESPERMETER;
+				size.setHeight( int(hImg *printer->resolution()) );
+			}
 		}
-
-
+    
 		if (size.width() > pdWidth || size.height() > pdHeight) {
 			int resp = KMessageBox::warningYesNoCancel(dialogParentWidget(),
 				i18n("The image will not fit on the page, what do you want to do?"),
Index: jpegformattype.cpp
===================================================================
--- jpegformattype.cpp	(revisione 626292)
+++ jpegformattype.cpp	(copia locale)
@@ -453,6 +453,29 @@
 
 			if(consumer) consumer->end();
 
+			// get the density X and Y info and the related units to have
+			// the aspect ratio of the image
+			// field: units -- one byte: Units for the X and Y densities
+			// 0 => no units, X and Y specify the pixel aspect ratio
+			// 1 => X and Y are dots per inch
+			// 2 => X and Y are dots per cm
+			// Xdensity -- two bytes 
+			// Ydensity -- two bytes
+			const float INCHESPERMETER = (100. / 2.54);
+			switch (mDecompress.density_unit)
+			{
+				case 0:  // no units
+				break;
+				case 1:  // dots per inch
+					image.setDotsPerMeterX(int(mDecompress.X_density * INCHESPERMETER));
+					image.setDotsPerMeterY(int(mDecompress.Y_density * INCHESPERMETER));
+				break;
+				case 2:  // dots per cm
+					image.setDotsPerMeterX(mDecompress.X_density * 100);
+					image.setDotsPerMeterY(mDecompress.Y_density * 100);
+				break;
+			}
+
 			mSourceManager.at_eof = true;
 
 			(void) jpeg_finish_decompress(&mDecompress);