[gtk/image-loading] png: Drop 16bit formats from saving for now



commit 84b969d8ba0b4a9c8817344579912a008a13ef52
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 13 21:50:55 2021 -0400

    png: Drop 16bit formats from saving for now
    
    We need to treat the load and save symmetrically,
    otherwise roundtrips don't work and tests fail.
    
    This will come back when we introduce colorspace
    handling more systematically.

 gdk/loaders/gdkpng.c | 53 ++++++----------------------------------------------
 1 file changed, 6 insertions(+), 47 deletions(-)
---
diff --git a/gdk/loaders/gdkpng.c b/gdk/loaders/gdkpng.c
index 9aca6fe682..11dac65eef 100644
--- a/gdk/loaders/gdkpng.c
+++ b/gdk/loaders/gdkpng.c
@@ -55,28 +55,6 @@ flip_02 (guchar *data,
     }
 }
 
-static void
-convert_float_to_16bit_inplace (float   *src,
-                                int      width,
-                                int      height)
-{
-  gsize x, y;
-  guint16 *dest = (guint16 *)src;
-
-  for (y = 0; y < height; y++)
-    {
-      for (x = 0; x < width; x++)
-        {
-          dest[4 * x    ] = (guint16) CLAMP(65536.f * src[x * 4    ], 0.f, 65535.f);
-          dest[4 * x + 1] = (guint16) CLAMP(65536.f * src[x * 4 + 1], 0.f, 65535.f);
-          dest[4 * x + 2] = (guint16) CLAMP(65536.f * src[x * 4 + 2], 0.f, 65535.f);
-          dest[4 * x + 3] = (guint16) CLAMP(65536.f * src[x * 4 + 3], 0.f, 65535.f);
-        }
-      dest += width * 4;
-      src += width * 4;
-    }
-} 
-
 /* }}} */
 /* {{{ Public API */
 
@@ -180,6 +158,12 @@ gdk_save_png (GdkTexture *texture)
     case GDK_MEMORY_A8B8G8R8:
     case GDK_MEMORY_R8G8B8:
     case GDK_MEMORY_B8G8R8:
+    case GDK_MEMORY_R16G16B16:
+    case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
+    case GDK_MEMORY_R16G16B16_FLOAT:
+    case GDK_MEMORY_R32G32B32_FLOAT:
+    case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
+    case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
       stride = image.width * 4;
       new_data = g_malloc (stride * image.height);
       gdk_texture_download (memory_texture, new_data, stride);
@@ -190,31 +174,6 @@ gdk_save_png (GdkTexture *texture)
       image.format = PNG_FORMAT_RGBA;
       break;
 
-    case GDK_MEMORY_R16G16B16:
-      data = gdk_memory_texture_get_data (GDK_MEMORY_TEXTURE (memory_texture));
-      stride = gdk_memory_texture_get_stride (GDK_MEMORY_TEXTURE (memory_texture));
-      image.format = PNG_FORMAT_LINEAR_RGB;
-      break;
-
-    case GDK_MEMORY_R16G16B16A16_PREMULTIPLIED:
-      data = gdk_memory_texture_get_data (GDK_MEMORY_TEXTURE (memory_texture));
-      stride = gdk_memory_texture_get_stride (GDK_MEMORY_TEXTURE (memory_texture));
-      image.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
-      break;
-
-    case GDK_MEMORY_R16G16B16_FLOAT:
-    case GDK_MEMORY_R32G32B32_FLOAT:
-    case GDK_MEMORY_R16G16B16A16_FLOAT_PREMULTIPLIED:
-    case GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED:
-      /* This isn't very efficient */
-      new_data = g_malloc (image.width * image.height * 16);
-      gdk_texture_download_float (memory_texture, (float *)new_data, image.width * 16);
-      convert_float_to_16bit_inplace ((float *)new_data, image.width, image.height);
-      data = new_data;
-      stride = image.width * 8;
-      image.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
-      break;
-
     case GDK_MEMORY_N_FORMATS:
     default:
       g_assert_not_reached ();


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