From 73a7ea3ae0d37ee28f90d6b38c49fda052638253 Mon Sep 17 00:00:00 2001 From: "edisonn@google.com" Date: Mon, 11 Nov 2013 20:55:15 +0000 Subject: Implement DPI for perspective bitmaps in PDF - we save the bitmap at the resolution requested. R=reed@google.com, vandebo@chromium.org Review URL: https://codereview.chromium.org/54913004 git-svn-id: http://skia.googlecode.com/svn/trunk@12230 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/gmmain.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gm/gmmain.cpp') diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index d1ab966abc..86a346da66 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -198,6 +198,7 @@ static PipeFlagComboData gPipeWritingFlagCombos[] = { }; static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap); +DECLARE_int32(pdfRasterDpi); const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() .plus(kMissingExpectations_ErrorType) @@ -636,7 +637,10 @@ public: SkMatrix initialTransform = gm->getInitialTransform(); if (FLAGS_useDocumentInsteadOfDevice) { SkISize pageISize = gm->getISize(); - SkAutoTUnref pdfDoc(SkDocument::CreatePDF(&pdf, NULL, encode_to_dct_data)); + SkAutoTUnref pdfDoc( + SkDocument::CreatePDF(&pdf, NULL, + encode_to_dct_data, + SkIntToScalar(FLAGS_pdfRasterDpi))); if (!pdfDoc.get()) { return false; @@ -667,6 +671,7 @@ public: dev = new SkPDFDevice(pageSize, contentSize, initialTransform); } dev->setDCTEncoder(encode_to_dct_data); + dev->setRasterDpi(SkIntToScalar(FLAGS_pdfRasterDpi)); SkAutoUnref aur(dev); SkCanvas c(dev); invokeGM(gm, &c, true, false); @@ -1475,7 +1480,10 @@ DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " // then we can write something reabable like --rotate centerx centery 90 DEFINE_bool(forcePerspectiveMatrix, false, "Force a perspective matrix."); DEFINE_bool(useDocumentInsteadOfDevice, false, "Use SkDocument::CreateFoo instead of SkFooDevice."); - +DEFINE_int32(pdfRasterDpi, 72, "Scale at which at which the non suported " + "features in PDF are rasterized. Must be be in range 0-10000. " + "Default is 72. N = 0 will disable rasterizing features like " + "text shadows or perspective bitmaps."); static SkData* encode_to_dct_data(size_t* pixelRefOffset, const SkBitmap& bitmap) { // Filter output of warnings that JPEG is not available for the image. if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return NULL; -- cgit v1.2.3