2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

Enhance QPDFMatrix API

This commit is contained in:
Jay Berkenbilt 2021-02-21 05:11:31 -05:00
parent 05eb5826d8
commit 901f1a788c
4 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2021-02-21 Jay Berkenbilt <ejb@ql.org>
* Allow QPDFObjectHandle::newArray and
QPDFObjectHandle::newFromMatrix take QPDFMatrix as well as
QPDFObjectHandle::Matrix
* Make member variables a--f of QPDFMatrix public
2021-02-20 Jay Berkenbilt <ejb@ql.org> 2021-02-20 Jay Berkenbilt <ejb@ql.org>
* Allow --rotate=0 to clear rotation from a page. * Allow --rotate=0 to clear rotation from a page.

View File

@ -90,7 +90,6 @@ class QPDFMatrix
QPDFObjectHandle::Rectangle transformRectangle( QPDFObjectHandle::Rectangle transformRectangle(
QPDFObjectHandle::Rectangle r); QPDFObjectHandle::Rectangle r);
private:
double a; double a;
double b; double b;
double c; double c;

View File

@ -47,6 +47,7 @@ class QPDF_Array;
class QPDFTokenizer; class QPDFTokenizer;
class QPDFExc; class QPDFExc;
class Pl_QPDFTokenizer; class Pl_QPDFTokenizer;
class QPDFMatrix;
class QPDFObjectHandle class QPDFObjectHandle
{ {
@ -522,6 +523,8 @@ class QPDFObjectHandle
QPDF_DLL QPDF_DLL
static QPDFObjectHandle newArray(Matrix const&); static QPDFObjectHandle newArray(Matrix const&);
QPDF_DLL QPDF_DLL
static QPDFObjectHandle newArray(QPDFMatrix const&);
QPDF_DLL
static QPDFObjectHandle newDictionary(); static QPDFObjectHandle newDictionary();
QPDF_DLL QPDF_DLL
static QPDFObjectHandle newDictionary( static QPDFObjectHandle newDictionary(
@ -535,6 +538,8 @@ class QPDFObjectHandle
// form of newArray. // form of newArray.
QPDF_DLL QPDF_DLL
static QPDFObjectHandle newFromMatrix(Matrix const&); static QPDFObjectHandle newFromMatrix(Matrix const&);
QPDF_DLL
static QPDFObjectHandle newFromMatrix(QPDFMatrix const&);
// Create a new stream and associate it with the given qpdf // Create a new stream and associate it with the given qpdf
// object. A subsequent call must be made to replaceStreamData() // object. A subsequent call must be made to replaceStreamData()

View File

@ -19,6 +19,7 @@
#include <qpdf/QPDFExc.hh> #include <qpdf/QPDFExc.hh>
#include <qpdf/QPDFPageObjectHelper.hh> #include <qpdf/QPDFPageObjectHelper.hh>
#include <qpdf/SparseOHArray.hh> #include <qpdf/SparseOHArray.hh>
#include <qpdf/QPDFMatrix.hh>
#include <qpdf/QTC.hh> #include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh> #include <qpdf/QUtil.hh>
@ -2566,6 +2567,19 @@ QPDFObjectHandle::newArray(Matrix const& matrix)
return newArray(items); return newArray(items);
} }
QPDFObjectHandle
QPDFObjectHandle::newArray(QPDFMatrix const& matrix)
{
std::vector<QPDFObjectHandle> items;
items.push_back(newReal(matrix.a));
items.push_back(newReal(matrix.b));
items.push_back(newReal(matrix.c));
items.push_back(newReal(matrix.d));
items.push_back(newReal(matrix.e));
items.push_back(newReal(matrix.f));
return newArray(items);
}
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newFromRectangle(Rectangle const& rect) QPDFObjectHandle::newFromRectangle(Rectangle const& rect)
{ {
@ -2573,9 +2587,15 @@ QPDFObjectHandle::newFromRectangle(Rectangle const& rect)
} }
QPDFObjectHandle QPDFObjectHandle
QPDFObjectHandle::newFromMatrix(Matrix const& rect) QPDFObjectHandle::newFromMatrix(Matrix const& m)
{ {
return newArray(rect); return newArray(m);
}
QPDFObjectHandle
QPDFObjectHandle::newFromMatrix(QPDFMatrix const& m)
{
return newArray(m);
} }
QPDFObjectHandle QPDFObjectHandle