Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2330)

Unified Diff: experimental/PdfViewer/pdf_viewer_main.cpp

Issue 19000004: add ability to specify the DPI at which to render the page (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: experimental/PdfViewer/pdf_viewer_main.cpp
===================================================================
--- experimental/PdfViewer/pdf_viewer_main.cpp (revision 10008)
+++ experimental/PdfViewer/pdf_viewer_main.cpp (working copy)
@@ -101,16 +101,21 @@
extern "C" SkCanvas* gDumpCanvas;
static bool render_page(const SkString& outputDir,
- const SkString& inputFilename,
- const SkPdfRenderer& renderer,
- int page) {
+ const SkString& inputFilename,
+ const SkPdfRenderer& renderer,
+ int page) {
SkRect rect = renderer.MediaBox(page < 0 ? 0 :page);
SkBitmap bitmap;
+ SkScalar width = SkScalarMul(rect.width(), SkDoubleToScalar(sqrt(FLAGS_DPI / 72.0)));
+ SkScalar height = SkScalarMul(rect.height(), SkDoubleToScalar(sqrt(FLAGS_DPI / 72.0)));
+
+ rect = SkRect::MakeWH(width, height);
+
#ifdef PDF_DEBUG_3X
- setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(rect.width()), 3 * (int)SkScalarToDouble(rect.height()));
+ setup_bitmap(&bitmap, 3 * (int)SkScalarToDouble(width), 3 * (int)SkScalarToDouble(height));
#else
- setup_bitmap(&bitmap, (int)SkScalarToDouble(rect.width()), (int)SkScalarToDouble(rect.height()));
+ setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height));
#endif
SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap)));
SkCanvas canvas(device);
@@ -118,7 +123,7 @@
gDumpBitmap = &bitmap;
gDumpCanvas = &canvas;
- renderer.renderPage(page < 0 ? 0 : page, &canvas);
+ renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
SkString outputPath;
if (!make_output_filepath(&outputPath, outputDir, inputFilename, page)) {

Powered by Google App Engine
This is Rietveld 408576698