summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2023-02-14 07:19:27 +0100
committerBenjamin Otte <otte@redhat.com>2023-02-15 00:39:18 +0100
commitb30af72125e2b79562223fecba5a7506df218f48 (patch)
tree8ded1c67d609f8950586e63ae8176f397bee347a /gdk
parenteb45b8083aa86d3a14e46d725d192fce0c946950 (diff)
downloadgtk+-b30af72125e2b79562223fecba5a7506df218f48.tar.gz
tiff: Use GdkTexureDownloader when saving
Diffstat (limited to 'gdk')
-rw-r--r--gdk/loaders/gdktiff.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/gdk/loaders/gdktiff.c b/gdk/loaders/gdktiff.c
index eab69bb2d9..489a962bd8 100644
--- a/gdk/loaders/gdktiff.c
+++ b/gdk/loaders/gdktiff.c
@@ -21,9 +21,9 @@
#include <glib/gi18n-lib.h>
#include "gdkmemoryformatprivate.h"
-#include "gdkmemorytextureprivate.h"
+#include "gdkmemorytexture.h"
#include "gdkprofilerprivate.h"
-#include "gdktexture.h"
+#include "gdktexturedownloaderprivate.h"
#include "gdktextureprivate.h"
#include <tiffio.h>
@@ -260,11 +260,12 @@ GBytes *
gdk_save_tiff (GdkTexture *texture)
{
TIFF *tif;
- int width, height, stride;
+ int width, height;
+ gsize stride;
const guchar *line;
const guchar *data;
- GBytes *result = NULL;
- GdkMemoryTexture *memtex;
+ GBytes *bytes, *result = NULL;
+ GdkTextureDownloader downloader;
GdkMemoryFormat format;
const FormatData *fdata = NULL;
@@ -292,9 +293,11 @@ gdk_save_tiff (GdkTexture *texture)
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- memtex = gdk_memory_texture_from_texture (texture, fdata->format);
- data = gdk_memory_texture_get_data (memtex);
- stride = gdk_memory_texture_get_stride (memtex);
+ gdk_texture_downloader_init (&downloader, texture);
+ gdk_texture_downloader_set_format (&downloader, fdata->format);
+ bytes = gdk_texture_downloader_download_bytes (&downloader, &stride);
+ gdk_texture_downloader_finish (&downloader);
+ data = g_bytes_get_data (bytes, NULL);
line = (const guchar *)data;
for (int y = 0; y < height; y++)
@@ -302,7 +305,7 @@ gdk_save_tiff (GdkTexture *texture)
if (TIFFWriteScanline (tif, (void *)line, y, 0) == -1)
{
TIFFClose (tif);
- g_object_unref (memtex);
+ g_bytes_unref (bytes);
return NULL;
}
@@ -314,7 +317,7 @@ gdk_save_tiff (GdkTexture *texture)
g_assert (result);
- g_object_unref (memtex);
+ g_bytes_unref (bytes);
return result;
}