[retro-gtk/pixbuf-aspect-ratio: 2/2] pixdata: Store the aspect ratio in pixbufs



commit 9de394a903e919f8d7721f5519fec084e22cbe6d
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Aug 11 23:18:34 2019 +0200

    pixdata: Store the aspect ratio in pixbufs
    
    When converting a RetroPixdata into a GdkPixbuf, store the unmodified
    aspect ratio in the aspect-ratio option of the pixbuf. This also
    deprecates the x-dpi and y-dpi options as they are more complex and
    confusing than aspect-ratio.

 retro-gtk/retro-pixdata.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/retro-gtk/retro-pixdata.c b/retro-gtk/retro-pixdata.c
index 4f2633b..ff5a4b0 100644
--- a/retro-gtk/retro-pixdata.c
+++ b/retro-gtk/retro-pixdata.c
@@ -321,6 +321,7 @@ retro_pixdata_to_pixbuf (RetroPixdata *self)
   gfloat x_dpi;
   g_autofree gchar *x_dpi_string = NULL;
   g_autofree gchar *y_dpi_string = NULL;
+  g_autofree gchar *aspect_ratio_string = NULL;
 
   g_return_val_if_fail (self != NULL, NULL);
 
@@ -343,11 +344,14 @@ retro_pixdata_to_pixbuf (RetroPixdata *self)
                                      self->width * sizeof (rgba8888),
                                      pixels_free, NULL);
 
+  /* x-dpi and y-dpi are deprecated, aspect-ratio should be used instead. */
   x_dpi = self->aspect_ratio * RETRO_CAIRO_DISPLAY_Y_DPI;
   x_dpi_string = g_strdup_printf ("%g", x_dpi);
   y_dpi_string = g_strdup_printf ("%g", RETRO_CAIRO_DISPLAY_Y_DPI);
+  aspect_ratio_string = g_strdup_printf ("%g", self->aspect_ratio);
   gdk_pixbuf_set_option (pixbuf, "x-dpi", x_dpi_string);
   gdk_pixbuf_set_option (pixbuf, "y-dpi", y_dpi_string);
+  gdk_pixbuf_set_option (pixbuf, "aspect-ratio", aspect_ratio_string);
 
   return pixbuf;
 }


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