forked from AuroraMiddleware/gtk
jpeg: Use GdkTexureDownloader when saving
This commit is contained in:
parent
4afec951c7
commit
f05d801e28
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
#include "gdktexture.h"
|
#include "gdktexture.h"
|
||||||
#include "gdkmemorytextureprivate.h"
|
#include "gdktexturedownloaderprivate.h"
|
||||||
|
|
||||||
#include "gdkprofilerprivate.h"
|
#include "gdkprofilerprivate.h"
|
||||||
|
|
||||||
@ -251,7 +251,8 @@ gdk_save_jpeg (GdkTexture *texture)
|
|||||||
guchar *data = NULL;
|
guchar *data = NULL;
|
||||||
gulong size = 0;
|
gulong size = 0;
|
||||||
guchar *input = NULL;
|
guchar *input = NULL;
|
||||||
GdkMemoryTexture *memtex = NULL;
|
GdkTextureDownloader downloader;
|
||||||
|
GBytes *texbytes;
|
||||||
const guchar *texdata;
|
const guchar *texdata;
|
||||||
gsize texstride;
|
gsize texstride;
|
||||||
guchar *row;
|
guchar *row;
|
||||||
@ -270,7 +271,7 @@ gdk_save_jpeg (GdkTexture *texture)
|
|||||||
free (data);
|
free (data);
|
||||||
g_free (input);
|
g_free (input);
|
||||||
jpeg_destroy_compress (&info);
|
jpeg_destroy_compress (&info);
|
||||||
g_clear_object (&memtex);
|
g_clear_pointer (&texbytes, g_bytes_unref);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,10 +290,11 @@ gdk_save_jpeg (GdkTexture *texture)
|
|||||||
|
|
||||||
jpeg_mem_dest (&info, &data, &size);
|
jpeg_mem_dest (&info, &data, &size);
|
||||||
|
|
||||||
memtex = gdk_memory_texture_from_texture (texture,
|
gdk_texture_downloader_init (&downloader, texture);
|
||||||
GDK_MEMORY_R8G8B8);
|
gdk_texture_downloader_set_format (&downloader, GDK_MEMORY_R8G8B8);
|
||||||
texdata = gdk_memory_texture_get_data (memtex);
|
texbytes = gdk_texture_downloader_download_bytes (&downloader, &texstride);
|
||||||
texstride = gdk_memory_texture_get_stride (memtex);
|
gdk_texture_downloader_finish (&downloader);
|
||||||
|
texdata = g_bytes_get_data (texbytes, NULL);
|
||||||
|
|
||||||
jpeg_start_compress (&info, TRUE);
|
jpeg_start_compress (&info, TRUE);
|
||||||
|
|
||||||
@ -304,7 +306,7 @@ gdk_save_jpeg (GdkTexture *texture)
|
|||||||
|
|
||||||
jpeg_finish_compress (&info);
|
jpeg_finish_compress (&info);
|
||||||
|
|
||||||
g_object_unref (memtex);
|
g_bytes_unref (texbytes);
|
||||||
g_free (input);
|
g_free (input);
|
||||||
jpeg_destroy_compress (&info);
|
jpeg_destroy_compress (&info);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user