]> git.imager.perl.org - imager.git/blobdiff - rotate.c
update TODO
[imager.git] / rotate.c
index 207d2d693b04e0b90059a336a24f89da061054b3..6dee34fcfdd68b9364b015ae8fb469db8f5b8313 100644 (file)
--- a/rotate.c
+++ b/rotate.c
@@ -16,7 +16,7 @@ Other rotations will be added as tuits become available.
 =cut
 */
 
-#include "image.h"
+#include "imager.h"
 #include <math.h> /* for floor() */
 
 i_img *i_rotate90(i_img *src, int degrees) {
@@ -178,14 +178,13 @@ static i_fcolor interp_i_fcolor(i_fcolor before, i_fcolor after, double pos,
   return out;
 }
 
-i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
-                            i_color *backp, i_fcolor *fbackp) {
+i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, const double *matrix,
+                            const i_color *backp, const i_fcolor *fbackp) {
   i_img *result = i_sametype(src, xsize, ysize);
   int x, y;
   int ch;
   int i, j;
   double sx, sy, sz;
-  double out[3];
 
   if (src->type == i_direct_type) {
     if (src->bits == i_8_bits) {
@@ -216,6 +215,9 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
             sx = (x * matrix[0] + y * matrix[1] + matrix[2]) / sz;
             sy = (x * matrix[3] + y * matrix[4] + matrix[5]) / sz;
           }
+         else {
+           sx = sy = 0;
+         }
 
           /* anything outside these ranges is either a broken co-ordinate
              or outside the source */
@@ -291,6 +293,9 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
             sx = (x * matrix[0] + y * matrix[1] + matrix[2]) / sz;
             sy = (x * matrix[3] + y * matrix[4] + matrix[5]) / sz;
           }
+          else {
+            sx = sy = 0;
+          }
 
           /* anything outside these ranges is either a broken co-ordinate
              or outside the source */
@@ -391,6 +396,9 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
           sx = (x * matrix[0] + y * matrix[1] + matrix[2]) / sz;
           sy = (x * matrix[3] + y * matrix[4] + matrix[5]) / sz;
         }
+        else {
+          sx = sy = 0;
+        }
         
         /* anything outside these ranges is either a broken co-ordinate
            or outside the source */
@@ -416,12 +424,12 @@ i_img *i_matrix_transform_bg(i_img *src, int xsize, int ysize, double *matrix,
   return result;
 }
 
-i_img *i_matrix_transform(i_img *src, int xsize, int ysize, double *matrix) {
+i_img *i_matrix_transform(i_img *src, int xsize, int ysize, const double *matrix) {
   return i_matrix_transform_bg(src, xsize, ysize, matrix, NULL, NULL);
 }
 
-
-i_matrix_mult(double *dest, double *left, double *right) {
+static void
+i_matrix_mult(double *dest, const double *left, const double *right) {
   int i, j, k;
   double accum;
   
@@ -437,7 +445,7 @@ i_matrix_mult(double *dest, double *left, double *right) {
 }
 
 i_img *i_rotate_exact_bg(i_img *src, double amount, 
-                        i_color *backp, i_fcolor *fbackp) {
+                        const i_color *backp, const i_fcolor *fbackp) {
   double xlate1[9] = { 0 };
   double rotate[9];
   double xlate2[9] = { 0 };