Browse Source

Fixes for issue 267/268. Added arg screenWidth (defaults 1024). Changed fmt to default to jpg

Christian Sciberras 15 years ago
parent
commit
442ed72499
5 changed files with 30 additions and 19 deletions
  1. 2 0
      .gitignore
  2. 2 1
      src/image/arguments.cc
  3. 4 1
      src/image/imageconverter.cc
  4. 18 17
      src/image/settings.cc
  5. 4 0
      src/image/settings.hh

+ 2 - 0
.gitignore

@@ -10,3 +10,5 @@ static-build/
 doc/
 man1/
 Makefile
+gitcontrol.bat
+gitcmd.lnk

+ 2 - 1
src/image/arguments.cc

@@ -27,6 +27,7 @@ CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
 
 	extended(false);
 	qthack(false);
+	addarg("width",0,"Set screen width (default is 1024)", new IntSetter(s.screenWidth,"int"));
 	addarg("scale-w",0,"Set width for resizing", new IntSetter(s.scale.width,"int"));
 	addarg("scale-h",0,"Set height for resizing", new IntSetter(s.scale.height,"int"));
 
@@ -34,7 +35,7 @@ CommandLineParser::CommandLineParser(wkhtmltopdf::settings::Global & s):
 	addarg("crop-y",0,"Set y coordinate for croping", new IntSetter(s.crop.top,"int"));
 	addarg("crop-w",0,"Set width for croping", new IntSetter(s.crop.width,"int"));
 	addarg("crop-h",0,"Set height for croping", new IntSetter(s.crop.height,"int"));
-	addarg("format",'f',"Output format", new QStrSetter(s.fmt, "format") );
+	addarg("format",'f',"Output file format (default is jpg)", new QStrSetter(s.fmt, "format") );
 	extended(true);
 	qthack(true);
 

+ 4 - 1
src/image/imageconverter.cc

@@ -93,7 +93,10 @@ void ImageConverterPrivate::pagesLoaded(bool ok) {
 	currentPhase=1;
 	emit out. phaseChanged();
 	loadProgress(0);
-	loaderObject->page.setViewportSize(loaderObject->page.mainFrame()->contentsSize());
+
+	if(settings.screenWidth<=0)settings.screenWidth=1024;
+	loaderObject->page.setViewportSize(QSize(settings.screenWidth,loaderObject->page.mainFrame()->contentsSize().height()));
+
 	QImage image(loaderObject->page.viewportSize(), QImage::Format_ARGB32_Premultiplied);
 	QPainter painter(&image);
 	if (!settings.transparent || settings.fmt != "png")

+ 18 - 17
src/image/settings.cc

@@ -17,25 +17,26 @@
 #include "settings.hh"
 
 namespace wkhtmltopdf {
-namespace settings {
+	namespace settings {
 
-CropSettings:: CropSettings():
-	left(0),
-	top(0),
-	width(-1),
-	height(-1) {}
+	CropSettings:: CropSettings():
+		left(0),
+		top(0),
+		width(-1),
+		height(-1) {}
 
-ScaleSettings::ScaleSettings():
-	width(-1),
-	height(-1) {}
+	ScaleSettings::ScaleSettings():
+		width(-1),
+		height(-1) {}
 
-Global::Global():
-	quiet(false),
-	transparent(false),
-	useGraphics(false),
-	in(""),
-	out(""),
-	fmt("") {}
+	Global::Global():
+		screenWidth(1024),
+		quiet(false),
+		transparent(false),
+		useGraphics(false),
+		in(""),
+		out(""),
+		fmt("jpg") {}
 
-}
+	}
 }

+ 4 - 0
src/image/settings.hh

@@ -77,6 +77,10 @@ struct Global {
 	QString out;
 	//! The output format
 	QString fmt;
+
+	//! Set the screen width
+	int screenWidth;
+
 };
 
 }