2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00

Add const versions of QPDFMatrix::transform*

This commit is contained in:
Jay Berkenbilt 2021-02-18 11:27:25 -05:00
parent de8929a41c
commit 71e8627285
2 changed files with 19 additions and 0 deletions

View File

@ -74,12 +74,19 @@ class QPDFMatrix
// [x y 1] * this // [x y 1] * this
// and take the first and second rows of the result as xp and yp. // and take the first and second rows of the result as xp and yp.
QPDF_DLL 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); void transform(double x, double y, double& xp, double& yp);
// Transform a rectangle by creating a new rectangle that tightly // Transform a rectangle by creating a new rectangle that tightly
// bounds the polygon resulting from transforming the four // bounds the polygon resulting from transforming the four
// corners. // corners.
QPDF_DLL QPDF_DLL
QPDFObjectHandle::Rectangle transformRectangle(
QPDFObjectHandle::Rectangle r) const;
// ABI: delete non-const version
QPDF_DLL
QPDFObjectHandle::Rectangle transformRectangle( QPDFObjectHandle::Rectangle transformRectangle(
QPDFObjectHandle::Rectangle r); QPDFObjectHandle::Rectangle r);

View File

@ -110,6 +110,12 @@ QPDFMatrix::rotatex90(int angle)
void void
QPDFMatrix::transform(double x, double y, double& xp, double& yp) 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; xp = (this->a * x) + (this->c * y) + this->e;
yp = (this->b * x) + (this->d * y) + this->f; yp = (this->b * x) + (this->d * y) + this->f;
@ -117,6 +123,12 @@ QPDFMatrix::transform(double x, double y, double& xp, double& yp)
QPDFObjectHandle::Rectangle QPDFObjectHandle::Rectangle
QPDFMatrix::transformRectangle(QPDFObjectHandle::Rectangle r) 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> tx(4);
std::vector<double> ty(4); std::vector<double> ty(4);