[gnome-photos/wip/rishi/buffer-decoder: 7/15] gegl: Add a function to calculate the inverse Jacobian for zooming



commit 4ea7c071583dd09c0ed3f59a6d7aa3e7a2dbd537
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Sep 24 11:36:21 2018 +0200

    gegl: Add a function to calculate the inverse Jacobian for zooming
    
    This will be necessary to support arbitrary downscales, without keeping
    the aspect ratio, in the new codec API for GeglBuffer. It is something
    that every codec will need and is, therefore, useful to have as a
    separate utility function.
    
    https://gitlab.gnome.org/GNOME/gnome-photos/issues/63

 src/photos-gegl.c | 20 ++++++++++++++++++++
 src/photos-gegl.h |  4 ++++
 2 files changed, 24 insertions(+)
---
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
index b3b02cff..5de85a8d 100644
--- a/src/photos-gegl.c
+++ b/src/photos-gegl.c
@@ -649,6 +649,26 @@ photos_gegl_init_fishes (void)
 }
 
 
+void
+photos_gegl_inverse_jacobian_zoom (GeglMatrix2 *inverse_jacobian, gdouble zoom_x, gdouble zoom_y)
+{
+  GeglMatrix3 tmp;
+
+  g_return_if_fail (inverse_jacobian != NULL);
+
+  gegl_matrix3_identity (&tmp);
+  tmp.coeff[0][0] = zoom_x;
+  tmp.coeff[1][1] = zoom_y;
+
+  gegl_matrix3_invert (&tmp);
+
+  inverse_jacobian->coeff[0][0] = tmp.coeff[0][0];
+  inverse_jacobian->coeff[0][1] = tmp.coeff[0][1];
+  inverse_jacobian->coeff[1][0] = tmp.coeff[1][0];
+  inverse_jacobian->coeff[1][1] = tmp.coeff[1][1];
+}
+
+
 static gboolean
 photos_gegl_processor_process_idle (gpointer user_data)
 {
diff --git a/src/photos-gegl.h b/src/photos-gegl.h
index d902300b..5e49169c 100644
--- a/src/photos-gegl.h
+++ b/src/photos-gegl.h
@@ -51,6 +51,10 @@ void             photos_gegl_init                         (void);
 
 void             photos_gegl_init_fishes                  (void);
 
+void             photos_gegl_inverse_jacobian_zoom        (GeglMatrix2 *out_inverse_jacobian,
+                                                           gdouble zoom_x,
+                                                           gdouble zoom_y);
+
 void             photos_gegl_processor_process_async      (GeglProcessor *processor,
                                                            GCancellable *cancellable,
                                                            GAsyncReadyCallback callback,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]