[poppler]
poppler/poppler: CairoOutputDev.cc, 1.19, 1.20 GfxState.cc,
1.2, 1.3 GfxState.h, 1.2, 1.3 TextOutputDev.cc, 1.8, 1.9
Kristian Hogsberg
krh at freedesktop.org
Sat Aug 6 08:30:22 EST 2005
Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv4401/poppler
Modified Files:
CairoOutputDev.cc GfxState.cc GfxState.h TextOutputDev.cc
Log Message:
2005-08-05 Kristian Høgsberg <krh at redhat.com>
* poppler/TextOutputDev.cc (visitLine): Round selection
coordinates in device space, so selection isn't fuzzy.
* poppler/GfxState.cc:
* poppler/GfxState.h: Add simple Matrix class.
Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- CairoOutputDev.cc 28 Jul 2005 17:34:19 -0000 1.19
+++ CairoOutputDev.cc 5 Aug 2005 22:30:20 -0000 1.20
@@ -260,14 +260,14 @@
j = 1;
while (j < subpath->getNumPoints()) {
if (subpath->getCurve(j)) {
+ state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
+ state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2);
+ state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3);
if (snapToGrid) {
x1 = round (x1); y1 = round (y1);
x2 = round (x2); y2 = round (y2);
x3 = round (x3); y3 = round (y3);
}
- state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
- state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2);
- state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3);
cairo_curve_to (cairo,
x1, y1,
x2, y2,
Index: GfxState.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxState.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- GfxState.cc 26 May 2005 12:52:38 -0000 1.2
+++ GfxState.cc 5 Aug 2005 22:30:20 -0000 1.3
@@ -28,6 +28,32 @@
return (x < 0) ? 0 : ((x > 1) ? 1 : x);
}
+GBool Matrix::invertTo(Matrix *other)
+{
+ double det;
+
+ det = 1 / (m[0] * m[3] - m[1] * m[2]);
+ other->m[0] = m[3] * det;
+ other->m[1] = -m[1] * det;
+ other->m[2] = -m[2] * det;
+ other->m[3] = m[0] * det;
+ other->m[4] = (m[2] * m[5] - m[3] * m[4]) * det;
+ other->m[5] = (m[1] * m[4] - m[0] * m[5]) * det;
+
+ return gTrue;
+}
+
+void Matrix::transform(double x, double y, double *tx, double *ty)
+{
+ double temp_x, temp_y;
+
+ temp_x = m[0] * x + m[2] * y + m[4];
+ temp_y = m[1] * x + m[3] * y + m[5];
+
+ *tx = temp_x;
+ *ty = temp_y;
+}
+
//------------------------------------------------------------------------
static char *gfxColorSpaceModeNames[] = {
Index: GfxState.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/GfxState.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- GfxState.h 26 May 2005 12:52:38 -0000 1.2
+++ GfxState.h 5 Aug 2005 22:30:20 -0000 1.3
@@ -22,6 +22,15 @@
class PDFRectangle;
class GfxShading;
+class Matrix {
+public:
+ double m[6];
+
+ GBool invertTo(Matrix *other);
+ void transform(double x, double y, double *tx, double *ty);
+};
+
+
//------------------------------------------------------------------------
// GfxColor
//------------------------------------------------------------------------
@@ -878,6 +887,7 @@
// Accessors.
double *getCTM() { return ctm; }
+ void getCTM(Matrix *m) { memcpy (m->m, ctm, sizeof m->m); }
double getX1() { return px1; }
double getY1() { return py1; }
double getX2() { return px2; }
Index: TextOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/TextOutputDev.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- TextOutputDev.cc 5 Aug 2005 19:04:36 -0000 1.8
+++ TextOutputDev.cc 5 Aug 2005 22:30:20 -0000 1.9
@@ -3254,6 +3254,7 @@
{
double x1, y1, x2, y2, margin;
int i;
+ Matrix ctm, ictm;
state->setFillColor(box_color);
out->updateFillColor(state);
@@ -3264,6 +3265,19 @@
x2 = ceil (line->edge[edge_end]);
y2 = ceil (line->yMax + margin);
+ state->getCTM (&ctm);
+ ctm.transform(line->edge[edge_begin], line->yMin - margin, &x1, &y1);
+ ctm.transform(line->edge[edge_end], line->yMax + margin, &x2, &y2);
+
+ x1 = floor (x1);
+ y1 = floor (y1);
+ x2 = ceil (x2);
+ y2 = ceil (y2);
+
+ ctm.invertTo (&ictm);
+ ictm.transform(x1, y1, &x1, &y1);
+ ictm.transform(x2, y2, &x2, &y2);
+
state->moveTo(x1, y1);
state->lineTo(x2, y1);
state->lineTo(x2, y2);
More information about the poppler
mailing list