1/* gdktexture.h
2 *
3 * Copyright 2016 Benjamin Otte
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __GDK_TEXTURE_H__
20#define __GDK_TEXTURE_H__
21
22#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
23#error "Only <gdk/gdk.h> can be included directly."
24#endif
25
26#include <gdk/gdkversionmacros.h>
27#include <gdk/gdktypes.h>
28#include <gdk-pixbuf/gdk-pixbuf.h>
29
30G_BEGIN_DECLS
31
32#define GDK_TYPE_TEXTURE (gdk_texture_get_type ())
33
34#define GDK_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_TEXTURE, GdkTexture))
35#define GDK_IS_TEXTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_TEXTURE))
36
37G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkTexture, g_object_unref)
38
39typedef struct _GdkTextureClass GdkTextureClass;
40
41#define GDK_TEXTURE_ERROR (gdk_texture_error_quark ())
42
43GDK_AVAILABLE_IN_4_6
44GQuark gdk_texture_error_quark (void);
45
46/**
47 * GdkTextureError:
48 * @GDK_TEXTURE_ERROR_TOO_LARGE: Not enough memory to handle this image
49 * @GDK_TEXTURE_ERROR_CORRUPT_IMAGE: The image data appears corrupted
50 * @GDK_TEXTURE_ERROR_UNSUPPORTED_CONTENT: The image contains features
51 * that cannot be loaded
52 * @GDK_TEXTURE_ERROR_UNSUPPORTED_FORMAT: The image format is not supported
53 *
54 * Possible errors that can be returned by `GdkTexture` constructors.
55 *
56 * Since: 4.6
57 */
58typedef enum
59{
60 GDK_TEXTURE_ERROR_TOO_LARGE,
61 GDK_TEXTURE_ERROR_CORRUPT_IMAGE,
62 GDK_TEXTURE_ERROR_UNSUPPORTED_CONTENT,
63 GDK_TEXTURE_ERROR_UNSUPPORTED_FORMAT,
64} GdkTextureError;
65
66GDK_AVAILABLE_IN_ALL
67GType gdk_texture_get_type (void) G_GNUC_CONST;
68
69GDK_AVAILABLE_IN_ALL
70GdkTexture * gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf);
71GDK_AVAILABLE_IN_ALL
72GdkTexture * gdk_texture_new_from_resource (const char *resource_path);
73GDK_AVAILABLE_IN_ALL
74GdkTexture * gdk_texture_new_from_file (GFile *file,
75 GError **error);
76GDK_AVAILABLE_IN_4_6
77GdkTexture * gdk_texture_new_from_filename (const char *path,
78 GError **error);
79GDK_AVAILABLE_IN_4_6
80GdkTexture * gdk_texture_new_from_bytes (GBytes *bytes,
81 GError **error);
82
83GDK_AVAILABLE_IN_ALL
84int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
85GDK_AVAILABLE_IN_ALL
86int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
87
88GDK_AVAILABLE_IN_ALL
89void gdk_texture_download (GdkTexture *texture,
90 guchar *data,
91 gsize stride);
92GDK_AVAILABLE_IN_ALL
93gboolean gdk_texture_save_to_png (GdkTexture *texture,
94 const char *filename);
95GDK_AVAILABLE_IN_4_6
96GBytes * gdk_texture_save_to_png_bytes (GdkTexture *texture);
97GDK_AVAILABLE_IN_4_6
98gboolean gdk_texture_save_to_tiff (GdkTexture *texture,
99 const char *filename);
100GDK_AVAILABLE_IN_4_6
101GBytes * gdk_texture_save_to_tiff_bytes (GdkTexture *texture);
102
103G_END_DECLS
104
105#endif /* __GDK_TEXTURE_H__ */
106

source code of gtk/gdk/gdktexture.h