[poppler] 6 commits - poppler/GfxState.cc poppler/GfxState.h poppler/SplashOutputDev.cc poppler/TextOutputDev.h utils/pdftohtml.1 utils/pdftohtml.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Fri Aug 27 11:32:46 PDT 2010
poppler/GfxState.cc | 27 +++++++++++++--------------
poppler/GfxState.h | 4 +++-
poppler/SplashOutputDev.cc | 39 ++++++++++++++++++++++++++++++---------
poppler/TextOutputDev.h | 4 ++--
utils/pdftohtml.1 | 3 +++
utils/pdftohtml.cc | 18 +++++++++++++-----
6 files changed, 64 insertions(+), 31 deletions(-)
New commits:
commit 681bb38eafc720b309172ed7c650439c559663a0
Author: Albert Astals Cid <aacid at kde.org>
Date: Thu Aug 26 23:55:58 2010 +0100
Make declaration match what there is in the .cc file
diff --git a/poppler/TextOutputDev.h b/poppler/TextOutputDev.h
index cceec20..438aee4 100644
--- a/poppler/TextOutputDev.h
+++ b/poppler/TextOutputDev.h
@@ -14,7 +14,7 @@
// Copyright (C) 2006 Ed Catmur <ed at catmur.co.uk>
// Copyright (C) 2007-2008 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright (C) 2007 Adrian Johnson <ajohnson at redneon.com>
-// Copyright (C) 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2008, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2010 Brian Ewins <brian.ewins at gmail.com>
//
// To see a description of the changes please see the Changelog file that
@@ -579,7 +579,7 @@ private:
~TextPage();
void clear();
- void assignColumns(TextLineFrag *frags, int nFrags, int rot);
+ void assignColumns(TextLineFrag *frags, int nFrags, GBool rot);
int dumpFragment(Unicode *text, int len, UnicodeMap *uMap, GooString *s);
GBool rawOrder; // keep text in content stream order
commit c91e869304fc263c52f21ee484a57a6f1900f6b2
Author: Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
Date: Thu Aug 26 19:40:46 2010 +0100
Add -r option to pdftohtml
Fixes bug 29551
diff --git a/utils/pdftohtml.1 b/utils/pdftohtml.1
index fbcc077..6cdc6c6 100644
--- a/utils/pdftohtml.1
+++ b/utils/pdftohtml.1
@@ -52,6 +52,9 @@ use standard output
.B \-zoom <fp>
zoom the pdf document (default 1.5)
.TP
+.B \-r <int>
+Specifies the resolution, in DPI (default 72 DPI)
+.TP
.B \-xml
output for XML post-processing
.TP
diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc
index 87a4d69..5762f90 100644
--- a/utils/pdftohtml.cc
+++ b/utils/pdftohtml.cc
@@ -16,6 +16,7 @@
// Copyright (C) 2007-2008, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
// Copyright (C) 2010 Mike Slegeir <tehpola at yahoo.com>
+// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -70,6 +71,7 @@ GBool ignore=gFalse;
GBool useSplash=gTrue;
char extension[5]="png";
double scale=1.5;
+int resolution=72;
GBool noframes=gFalse;
GBool stout=gFalse;
GBool xml=gFalse;
@@ -113,6 +115,8 @@ static const ArgDesc argDesc[] = {
"use standard output"},
{"-zoom", argFP, &scale, 0,
"zoom the pdf document (default 1.5)"},
+ {"-r", argInt, &resolution, 0,
+ "resolution to render the pdf document (default 72)"},
{"-xml", argFlag, &xml, 0,
"output for XML post-processing"},
{"-hidden", argFlag, &showHidden, 0,
@@ -419,13 +423,16 @@ int main(int argc, char *argv[]) {
pg_h = tmp;
}
- doc->displayPage(splashOut, pg, 72, 72, 0, gTrue, gFalse, gFalse);
+ doc->displayPage(splashOut, pg,
+ resolution, resolution,
+ 0, gTrue, gFalse, gFalse);
SplashBitmap *bitmap = splashOut->getBitmap();
imgFileName = GooString::format("{0:s}{1:03d}.{2:s}",
htmlFileName->getCString(), pg, extension);
- bitmap->writeImgFile(format, imgFileName->getCString(), 72, 72);
+ bitmap->writeImgFile(format, imgFileName->getCString(),
+ resolution, resolution);
delete imgFileName;
}
@@ -448,7 +455,7 @@ int main(int argc, char *argv[]) {
gTrue, gFalse, gFalse);
delete psOut;
- /*sprintf(buf, "%s -sDEVICE=png16m -dBATCH -dNOPROMPT -dNOPAUSE -r72 -sOutputFile=%s%%03d.png -g%dx%d -q %s", GHOSTSCRIPT, htmlFileName->getCString(), w, h,
+ /*sprintf(buf, "%s -sDEVICE=png16m -dBATCH -dNOPROMPT -dNOPAUSE -r%d -sOutputFile=%s%%03d.png -g%dx%d -q %s", GHOSTSCRIPT, resolution, htmlFileName->getCString(), w, h,
psFileName->getCString());*/
GooString *gsCmd = new GooString(GHOSTSCRIPT);
@@ -456,7 +463,7 @@ int main(int argc, char *argv[]) {
gsCmd->append(" -sDEVICE=");
gsCmd->append(gsDevice);
gsCmd->append(" -dBATCH -dNOPROMPT -dNOPAUSE -r");
- sc = GooString::fromInt(static_cast<int>(72*scale));
+ sc = GooString::fromInt(static_cast<int>(resolution*scale));
gsCmd->append(sc);
gsCmd->append(" -sOutputFile=");
gsCmd->append("\"");
@@ -464,10 +471,11 @@ int main(int argc, char *argv[]) {
gsCmd->append("%03d.");
gsCmd->append(extension);
gsCmd->append("\" -g");
- tw = GooString::fromInt(static_cast<int>(scale*w));
+ tw = GooString::fromInt(static_cast<int>(scale*w*resolution/72.0));
gsCmd->append(tw);
gsCmd->append("x");
th = GooString::fromInt(static_cast<int>(scale*h));
+ th = GooString::fromInt(static_cast<int>(scale*h*resolution/72.0));
gsCmd->append(th);
gsCmd->append(" -q \"");
gsCmd->append(psFileName);
commit 9b4be586640b4ad344b1b3ed4c9cda8351257f0c
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Aug 25 19:26:30 2010 +0100
Use 3 not nComps
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 88f3e05..59a8863 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -1585,7 +1585,7 @@ void GfxICCBasedColorSpace::getRGBLine(Guchar *in, unsigned int *out,
Guchar* tmp = (Guchar *)gmallocn(nComps * length, sizeof(Guchar));
lineTransform->doTransform(in, tmp, length);
for (int i = 0; i < length; ++i) {
- Guchar *current = tmp + (i*nComps);
+ Guchar *current = tmp + (i * 3);
out[i] = (current[0] << 16) | (current[1] << 8) | current[2];
}
gfree(tmp);
commit 218f67c527fb41babf2703ba068d072f8326e37b
Author: PaweÅ Wiejacha <pawel.wiejacha at gmail.com>
Date: Tue Aug 24 23:47:06 2010 +0100
Make SplashOutputDev::imageSrc faster
By using getRGBLine when possible
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc
index 21d7be6..666ee18 100644
--- a/poppler/SplashOutputDev.cc
+++ b/poppler/SplashOutputDev.cc
@@ -25,6 +25,7 @@
// Copyright (C) 2009 William Bader <williambader at hotmail.com>
// Copyright (C) 2010 Patrick Spendrin <ps_ml at gmx.de>
// Copyright (C) 2010 Brian Cameron <brian.cameron at oracle.com>
+// Copyright (C) 2010 PaweÅ Wiejacha <pawel.wiejacha at gmail.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -2087,7 +2088,6 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
SplashOutImageData *imgData = (SplashOutImageData *)data;
Guchar *p;
SplashColorPtr q, col;
- GfxRGB rgb;
GfxGray gray;
#if SPLASH_CMYK
GfxCMYK cmyk;
@@ -2160,14 +2160,35 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr colorLine,
case splashModeXBGR8:
case splashModeRGB8:
case splashModeBGR8:
- for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = colToByte(rgb.r);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.b);
- if (imgData->colorMode == splashModeXBGR8) *q++ = 255;
+ if (!imgData->colorMap->useRGBLine())
+ {
+ GfxRGB rgb;
+ for (x = 0, p = imgData->imgStr->getLine(), q = colorLine;
+ x < imgData->width;
+ ++x, p += nComps) {
+ imgData->colorMap->getRGB(p, &rgb);
+ *q++ = colToByte(rgb.r);
+ *q++ = colToByte(rgb.g);
+ *q++ = colToByte(rgb.b);
+ if (imgData->colorMode == splashModeXBGR8) *q++ = 255;
+ }
+ }
+ else
+ {
+ p = imgData->imgStr->getLine();
+ q = colorLine;
+ unsigned int* line = (unsigned int *)gmallocn(imgData->width, sizeof(unsigned int));
+
+ imgData->colorMap->getRGBLine(p, line, imgData->width);
+ for (x = 0; x < imgData->width; ++x) {
+ *q++ = (line[x] >> 16) & 255;
+ *q++ = (line[x] >> 8) & 255;
+ *q++ = (line[x]) & 255;
+ if (imgData->colorMode == splashModeXBGR8) {
+ *q++ = 255;
+ }
+ }
+ gfree(line);
}
break;
#if SPLASH_CMYK
commit 868f4a1f22051b7978f47a0614f23fd66dbb7ca8
Author: PaweÅ Wiejacha <pawel.wiejacha at gmail.com>
Date: Tue Aug 24 23:35:21 2010 +0100
Make GfxICCBasedColorSpace::getRGBLine faster
By calling doTransform less
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 0882781..88f3e05 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -1582,13 +1582,13 @@ void GfxICCBasedColorSpace::getRGBLine(Guchar *in, unsigned int *out,
int length) {
#ifdef USE_CMS
if (lineTransform != 0) {
- for (int i = 0;i < length;i++) {
- Guchar tmp[gfxColorMaxComps];
-
- lineTransform->doTransform(in,tmp,1);
- in += nComps;
- out[i] = (tmp[0] << 16) | (tmp[1] << 8) | tmp[2];
+ Guchar* tmp = (Guchar *)gmallocn(nComps * length, sizeof(Guchar));
+ lineTransform->doTransform(in, tmp, length);
+ for (int i = 0; i < length; ++i) {
+ Guchar *current = tmp + (i*nComps);
+ out[i] = (current[0] << 16) | (current[1] << 8) | current[2];
}
+ gfree(tmp);
} else {
alt->getRGBLine(in, out, length);
}
@@ -4249,8 +4249,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) {
int i, j;
Guchar *inp, *tmp_line;
- if ((colorSpace2 && !colorSpace2->useGetRGBLine ()) ||
- (!colorSpace2 && !colorSpace->useGetRGBLine ())) {
+ if (!useRGBLine()) {
GfxRGB rgb;
inp = in;
diff --git a/poppler/GfxState.h b/poppler/GfxState.h
index 7dccfd5..900214d 100644
--- a/poppler/GfxState.h
+++ b/poppler/GfxState.h
@@ -17,7 +17,7 @@
// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
// Copyright (C) 2006 Carlos Garcia Campos <carlosgc at gnome.org>
// Copyright (C) 2009 Koji Otani <sho at bbr.jp>
-// Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2009, 2010 Albert Astals Cid <aacid at kde.org>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -952,6 +952,8 @@ public:
// Get decode table.
double getDecodeLow(int i) { return decodeLow[i]; }
double getDecodeHigh(int i) { return decodeLow[i] + decodeRange[i]; }
+
+ bool useRGBLine() { return (colorSpace2 && colorSpace2->useGetRGBLine ()) || (!colorSpace2 && colorSpace->useGetRGBLine ()); }
// Convert an image pixel to a color.
void getGray(Guchar *x, GfxGray *gray);
commit 46e37c54c6365cf37dc1e223a3c146e7b96a56af
Author: PaweÅ Wiejacha <pawel.wiejacha at gmail.com>
Date: Tue Aug 24 21:23:34 2010 +0100
Do not call pow three times when one is enough
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 3be4171..0882781 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -20,6 +20,7 @@
// Copyright (C) 2009 Koji Otani <sho at bbr.jp>
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright (C) 2009 Christian Persch <chpe at gnome.org>
+// Copyright (C) 2010 PaweÅ Wiejacha <pawel.wiejacha at gmail.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -613,12 +614,11 @@ GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr) {
// (not multiply by the white point)
void GfxCalGrayColorSpace::getXYZ(GfxColor *color,
double *pX, double *pY, double *pZ) {
- double A;
-
- A = colToDbl(color->c[0]);
- *pX = pow(A,gamma);
- *pY = pow(A,gamma);
- *pZ = pow(A,gamma);
+ const double A = colToDbl(color->c[0]);
+ const double xyzColor = pow(A,gamma);
+ *pX = xyzColor;
+ *pY = xyzColor;
+ *pZ = xyzColor;
}
void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
More information about the poppler
mailing list