diff options
-rw-r--r-- | include/qpdf/QPDFMatrix.hh | 7 | ||||
-rw-r--r-- | libqpdf/QPDFMatrix.cc | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/include/qpdf/QPDFMatrix.hh b/include/qpdf/QPDFMatrix.hh index 85f42af7..8a8bff60 100644 --- a/include/qpdf/QPDFMatrix.hh +++ b/include/qpdf/QPDFMatrix.hh @@ -74,6 +74,9 @@ class QPDFMatrix // [x y 1] * this // and take the first and second rows of the result as xp and yp. QPDF_DLL + void transform(double x, double y, double& xp, double& yp) const; + // ABI: delete non-const version + QPDF_DLL void transform(double x, double y, double& xp, double& yp); // Transform a rectangle by creating a new rectangle that tightly @@ -81,6 +84,10 @@ class QPDFMatrix // corners. QPDF_DLL QPDFObjectHandle::Rectangle transformRectangle( + QPDFObjectHandle::Rectangle r) const; + // ABI: delete non-const version + QPDF_DLL + QPDFObjectHandle::Rectangle transformRectangle( QPDFObjectHandle::Rectangle r); private: diff --git a/libqpdf/QPDFMatrix.cc b/libqpdf/QPDFMatrix.cc index 18122d72..2b269099 100644 --- a/libqpdf/QPDFMatrix.cc +++ b/libqpdf/QPDFMatrix.cc @@ -111,6 +111,12 @@ QPDFMatrix::rotatex90(int angle) void QPDFMatrix::transform(double x, double y, double& xp, double& yp) { + const_cast<QPDFMatrix const*>(this)->transform(x, y, xp, yp); +} + +void +QPDFMatrix::transform(double x, double y, double& xp, double& yp) const +{ xp = (this->a * x) + (this->c * y) + this->e; yp = (this->b * x) + (this->d * y) + this->f; } @@ -118,6 +124,12 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp) QPDFObjectHandle::Rectangle QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) { + return const_cast<QPDFMatrix const*>(this)->transformRectangle(r); +} + +QPDFObjectHandle::Rectangle +QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) const +{ std::vector<double> tx(4); std::vector<double> ty(4); transform(r.llx, r.lly, tx.at(0), ty.at(0)); |