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 | |
30 | G_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 | |
37 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkTexture, g_object_unref) |
38 | |
39 | typedef struct _GdkTextureClass GdkTextureClass; |
40 | |
41 | #define GDK_TEXTURE_ERROR (gdk_texture_error_quark ()) |
42 | |
43 | GDK_AVAILABLE_IN_4_6 |
44 | GQuark 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 | */ |
58 | typedef 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 | |
66 | GDK_AVAILABLE_IN_ALL |
67 | GType gdk_texture_get_type (void) G_GNUC_CONST; |
68 | |
69 | GDK_AVAILABLE_IN_ALL |
70 | GdkTexture * gdk_texture_new_for_pixbuf (GdkPixbuf *pixbuf); |
71 | GDK_AVAILABLE_IN_ALL |
72 | GdkTexture * gdk_texture_new_from_resource (const char *resource_path); |
73 | GDK_AVAILABLE_IN_ALL |
74 | GdkTexture * gdk_texture_new_from_file (GFile *file, |
75 | GError **error); |
76 | GDK_AVAILABLE_IN_4_6 |
77 | GdkTexture * gdk_texture_new_from_filename (const char *path, |
78 | GError **error); |
79 | GDK_AVAILABLE_IN_4_6 |
80 | GdkTexture * gdk_texture_new_from_bytes (GBytes *bytes, |
81 | GError **error); |
82 | |
83 | GDK_AVAILABLE_IN_ALL |
84 | int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE; |
85 | GDK_AVAILABLE_IN_ALL |
86 | int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE; |
87 | |
88 | GDK_AVAILABLE_IN_ALL |
89 | void gdk_texture_download (GdkTexture *texture, |
90 | guchar *data, |
91 | gsize stride); |
92 | GDK_AVAILABLE_IN_ALL |
93 | gboolean gdk_texture_save_to_png (GdkTexture *texture, |
94 | const char *filename); |
95 | GDK_AVAILABLE_IN_4_6 |
96 | GBytes * gdk_texture_save_to_png_bytes (GdkTexture *texture); |
97 | GDK_AVAILABLE_IN_4_6 |
98 | gboolean gdk_texture_save_to_tiff (GdkTexture *texture, |
99 | const char *filename); |
100 | GDK_AVAILABLE_IN_4_6 |
101 | GBytes * gdk_texture_save_to_tiff_bytes (GdkTexture *texture); |
102 | |
103 | G_END_DECLS |
104 | |
105 | #endif /* __GDK_TEXTURE_H__ */ |
106 | |