[gtk/matthiasc/color-profile-rebased: 12/51] gtk-demo: Add a color space demo




commit e9315dbcf86ee210f89cd523337f6101b7f871b8
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 23 01:22:05 2021 -0400

    gtk-demo: Add a color space demo
    
    This is using test images from http://displaycal.net/.

 ...Rendering-Intent-Test-expected-result-no-cm.png | Bin 0 -> 24543 bytes
 demos/gtk-demo/ICC-Rendering-Intent-Test.jpg       | Bin 0 -> 297456 bytes
 demos/gtk-demo/ICC-Rendering-Intent-Test.png       | Bin 0 -> 123151 bytes
 demos/gtk-demo/ICC-Rendering-Intent-Test.tif       | Bin 0 -> 216166 bytes
 demos/gtk-demo/colorspaces.c                       |  86 +++++++++++++++++++
 demos/gtk-demo/colorspaces.ui                      |  94 +++++++++++++++++++++
 demos/gtk-demo/demo.gresource.xml                  |  12 +++
 demos/gtk-demo/meson.build                         |   1 +
 demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png | Bin 0 -> 5283 bytes
 demos/gtk-demo/sRGB_Gray.jpg                       | Bin 0 -> 36854 bytes
 demos/gtk-demo/sRGB_Gray.png                       | Bin 0 -> 4531 bytes
 demos/gtk-demo/sRGB_Gray.tif                       | Bin 0 -> 9104 bytes
 12 files changed, 193 insertions(+)
---
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png 
b/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png
new file mode 100644
index 0000000000..efafad94bf
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png differ
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg b/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg
new file mode 100644
index 0000000000..7f318cd73b
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg differ
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test.png b/demos/gtk-demo/ICC-Rendering-Intent-Test.png
new file mode 100644
index 0000000000..27819f0dd5
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test.png differ
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test.tif b/demos/gtk-demo/ICC-Rendering-Intent-Test.tif
new file mode 100644
index 0000000000..fe1030ca0f
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test.tif differ
diff --git a/demos/gtk-demo/colorspaces.c b/demos/gtk-demo/colorspaces.c
new file mode 100644
index 0000000000..f8f1c406e2
--- /dev/null
+++ b/demos/gtk-demo/colorspaces.c
@@ -0,0 +1,86 @@
+/* Color Spaces
+ *
+ * Demonstrates support for color spaces.
+ *
+ * The test images used here are taken from http://displaycal.net/icc-color-management-test/
+ * and are licensed under the Creative Commons BY-SA 4.0 International License
+ */
+
+#include <gtk/gtk.h>
+
+static GtkWidget *jpeg;
+static GtkWidget *png;
+static GtkWidget *tiff;
+static GtkWidget *noprofile;
+static GtkWidget *test1;
+static GtkWidget *test2;
+
+static void
+on_changed (GtkCheckButton *button,
+            gpointer        user_data)
+{
+  GdkTexture *texture;
+  const char *extension = NULL;
+  char *path;
+
+  if (!gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
+    return;
+
+  if (gtk_check_button_get_active (GTK_CHECK_BUTTON (jpeg)))
+    extension = ".jpg";
+  else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (png)))
+    extension = ".png";
+  else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (tiff)))
+    extension = ".tif";
+  else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (noprofile)))
+    extension = "-expected-result-no-cm.png";
+
+  path = g_strconcat ("/colorspaces/sRGB_Gray", extension, NULL);
+  texture = gdk_texture_new_from_resource (path);
+  gtk_picture_set_paintable (GTK_PICTURE (test1), GDK_PAINTABLE (texture));
+  g_object_unref (texture);
+
+  path = g_strconcat ("/colorspaces/ICC-Rendering-Intent-Test", extension, NULL);
+  texture = gdk_texture_new_from_resource (path);
+  gtk_picture_set_paintable (GTK_PICTURE (test2), GDK_PAINTABLE (texture));
+  g_object_unref (texture);
+}
+
+GtkWidget*
+do_colorspaces (GtkWidget *do_widget)
+{
+  static GtkWidget *window;
+
+  if (!window)
+    {
+      GtkBuilder *builder;
+      GtkBuilderScope *scope;
+
+      scope = gtk_builder_cscope_new ();
+      gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope),
+                                              "on_changed", G_CALLBACK (on_changed));
+
+      builder = gtk_builder_new ();
+      gtk_builder_set_scope (builder, scope);
+      gtk_builder_add_from_resource (builder, "/colorspaces/colorspaces.ui", NULL);
+      window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+      jpeg = GTK_WIDGET (gtk_builder_get_object (builder, "jpeg"));
+      png = GTK_WIDGET (gtk_builder_get_object (builder, "png"));
+      tiff = GTK_WIDGET (gtk_builder_get_object (builder, "tiff"));
+      noprofile = GTK_WIDGET (gtk_builder_get_object (builder, "noprofile"));
+      test1 = GTK_WIDGET (gtk_builder_get_object (builder, "test1"));
+      test2 = GTK_WIDGET (gtk_builder_get_object (builder, "test2"));
+      gtk_window_set_display (GTK_WINDOW (window),
+                              gtk_widget_get_display (do_widget));
+      g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
+      g_object_unref (builder);
+      g_object_unref (scope);
+    }
+
+  if (!gtk_widget_get_visible (window))
+    gtk_widget_show (window);
+  else
+    gtk_window_destroy (GTK_WINDOW (window));
+
+  return window;
+}
diff --git a/demos/gtk-demo/colorspaces.ui b/demos/gtk-demo/colorspaces.ui
new file mode 100644
index 0000000000..05416e51c8
--- /dev/null
+++ b/demos/gtk-demo/colorspaces.ui
@@ -0,0 +1,94 @@
+<interface>
+  <object class="GtkWindow" id="window">
+    <property name="default-width">660</property>
+    <property name="default-height">660</property>
+    <property name="resizable">false</property>
+    <property name="title">Color Profiles</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <child>
+          <object class="GtkBox">
+            <property name="orientation">vertical</property>
+            <property name="spacing">10</property>
+            <property name="margin-top">10</property>
+            <property name="margin-bottom">10</property>
+            <property name="margin-start">10</property>
+            <property name="margin-end">10</property>
+            <child>
+              <object class="GtkBox">
+                <property name="spacing">10</property>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="label">File format:</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="jpeg">
+                    <property name="label">JPEG</property>
+                    <property name="active">1</property>
+                    <signal name="notify::active" handler="on_changed"/>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="png">
+                    <property name="label">PNG</property>
+                    <property name="group">jpeg</property>
+                    <signal name="notify::active" handler="on_changed"/>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="tiff">
+                    <property name="label">TIFF</property>
+                    <property name="group">png</property>
+                    <signal name="notify::active" handler="on_changed"/>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="noprofile">
+                    <property name="label">No profile</property>
+                    <property name="group">tiff</property>
+                    <signal name="notify::active" handler="on_changed"/>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="label">Test 1: Matrix-based profile</property>
+                <style>
+                  <class name="title-3"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkPicture" id="test1">
+                <property name="hexpand">1</property>
+                <property name="vexpand">1</property>
+                <property name="can-shrink">1</property>
+                <property name="keep-aspect-ratio">1</property>
+                <property name="file">resource:///colorprofiles/sRGB_Gray.jpg</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel">
+                <property name="label">Test 2: Lookup table-based profile</property>
+                <style>
+                  <class name="title-3"/>
+                </style>
+              </object>
+            </child>
+            <child>
+              <object class="GtkPicture" id="test2">
+                <property name="hexpand">1</property>
+                <property name="vexpand">1</property>
+                <property name="can-shrink">1</property>
+                <property name="keep-aspect-ratio">1</property>
+                <property name="file">resource:///colorprofiles/ICC-Rendering-Intent-Test.jpg</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 65b87365e2..d0c3ef11d1 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -19,6 +19,17 @@
     <file>demoimage.c</file>
     <file>demoimage.h</file>
   </gresource>
+  <gresource prefix="/colorspaces">
+    <file>colorspaces.ui</file>
+    <file>sRGB_Gray.jpg</file>
+    <file>sRGB_Gray.png</file>
+    <file>sRGB_Gray.tif</file>
+    <file>sRGB_Gray-expected-result-no-cm.png</file>
+    <file>ICC-Rendering-Intent-Test.png</file>
+    <file>ICC-Rendering-Intent-Test.jpg</file>
+    <file>ICC-Rendering-Intent-Test.tif</file>
+    <file>ICC-Rendering-Intent-Test-expected-result-no-cm.png</file>
+  </gresource>
   <gresource prefix="/constraints_builder">
     <file>constraints_builder.ui</file>
   </gresource>
@@ -255,6 +266,7 @@
     <file>assistant.c</file>
     <file>builder.c</file>
     <file>clipboard.c</file>
+    <file>colorspaces.c</file>
     <file>combobox.c</file>
     <file>constraints.c</file>
     <file>constraints_interactive.c</file>
diff --git a/demos/gtk-demo/meson.build b/demos/gtk-demo/meson.build
index ef89fbc7d2..307d586c18 100644
--- a/demos/gtk-demo/meson.build
+++ b/demos/gtk-demo/meson.build
@@ -5,6 +5,7 @@ demos = files([
   'assistant.c',
   'builder.c',
   'clipboard.c',
+  'colorspaces.c',
   'combobox.c',
   'constraints.c',
   'constraints_interactive.c',
diff --git a/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png 
b/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png
new file mode 100644
index 0000000000..cc9873f283
Binary files /dev/null and b/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png differ
diff --git a/demos/gtk-demo/sRGB_Gray.jpg b/demos/gtk-demo/sRGB_Gray.jpg
new file mode 100644
index 0000000000..fe58ddbf8c
Binary files /dev/null and b/demos/gtk-demo/sRGB_Gray.jpg differ
diff --git a/demos/gtk-demo/sRGB_Gray.png b/demos/gtk-demo/sRGB_Gray.png
new file mode 100644
index 0000000000..b13816b427
Binary files /dev/null and b/demos/gtk-demo/sRGB_Gray.png differ
diff --git a/demos/gtk-demo/sRGB_Gray.tif b/demos/gtk-demo/sRGB_Gray.tif
new file mode 100644
index 0000000000..6685ac6402
Binary files /dev/null and b/demos/gtk-demo/sRGB_Gray.tif differ


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