]> mj.ucw.cz Git - paperjam.git/blobdiff - pdf-tools.cc
Page rotation is now a part of pdf-tools
[paperjam.git] / pdf-tools.cc
index 0871637b34044bfc99ce31c6790260ab962b3799..0d74ca37b3a5c8aaac19a298a0b0dbebe706e91b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Auxiliary functions for processing PDF files
  *
- *     (c) 2018 Martin Mares <mj@ucw.cz>
+ *     (c) 2018--2022 Martin Mares <mj@ucw.cz>
  */
 
 #include <cstdio>
@@ -247,3 +247,29 @@ string pdf_coord(double x, uint digits)
                buf[--n] = 0;
        return buf;
 }
+
+/*** Rotation matrix construction ***/
+
+pdf_matrix pdf_rotation_matrix(int deg, double width, double height)
+{
+      pdf_matrix m;
+      switch (deg) {
+             case 0:
+                     break;
+             case 90:
+                     m.rotate_deg(-90);
+                     m.shift(0, width);
+                     break;
+             case 180:
+                     m.rotate_deg(180);
+                     m.shift(width, height);
+                     break;
+             case 270:
+                     m.rotate_deg(90);
+                     m.shift(height, 0);
+                     break;
+             default:
+                     abort();
+      }
+      return m;
+}