| 1 /* pidgin |
|
| 2 * |
|
| 3 * Pidgin is the legal property of its developers, whose names are too numerous |
|
| 4 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
| 5 * source distribution. |
|
| 6 * |
|
| 7 * This program is free software; you can redistribute it and/or modify |
|
| 8 * it under the terms of the GNU General Public License as published by |
|
| 9 * the Free Software Foundation; either version 2 of the License, or |
|
| 10 * (at your option) any later version. |
|
| 11 * |
|
| 12 * This program is distributed in the hope that it will be useful, |
|
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 * GNU General Public License for more details. |
|
| 16 * |
|
| 17 * You should have received a copy of the GNU General Public License |
|
| 18 * along with this program; if not, write to the Free Software |
|
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
| 20 */ |
|
| 21 |
|
| 22 #if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION) |
|
| 23 # error "only <pidgin.h> may be included directly" |
|
| 24 #endif |
|
| 25 |
|
| 26 #ifndef PIDGIN_GDK_PIXBUF_H |
|
| 27 #define PIDGIN_GDK_PIXBUF_H |
|
| 28 |
|
| 29 #include <glib.h> |
|
| 30 #include <gdk-pixbuf/gdk-pixbuf.h> |
|
| 31 |
|
| 32 #include <purple.h> |
|
| 33 |
|
| 34 G_BEGIN_DECLS |
|
| 35 |
|
| 36 /** |
|
| 37 * pidgin_gdk_pixbuf_new_from_image: |
|
| 38 * @image: A #PurpleImage instance. |
|
| 39 * @error: (out) (nullable): A return address for a #GError. |
|
| 40 * |
|
| 41 * Creates a new #GdkPixbuf from the #PurpleImage @image. If provided Sets |
|
| 42 * @error on error. |
|
| 43 * |
|
| 44 * Returns: (transfer full) (nullable): The new #GdkPixbuf or %NULL or error. |
|
| 45 */ |
|
| 46 GdkPixbuf *pidgin_gdk_pixbuf_new_from_image(PurpleImage *image, GError **error); |
|
| 47 |
|
| 48 /** |
|
| 49 * pidgin_gdk_pixbuf_make_round: |
|
| 50 * @pixbuf: The buddy icon to transform |
|
| 51 * |
|
| 52 * Rounds the corners of a GdkPixbuf in place. |
|
| 53 */ |
|
| 54 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf); |
|
| 55 |
|
| 56 /** |
|
| 57 * pidgin_gdk_pixbuf_is_opaque: |
|
| 58 * @pixbuf: The pixbuf |
|
| 59 * |
|
| 60 * Returns TRUE if the GdkPixbuf is opaque, as determined by no |
|
| 61 * alpha at any of the edge pixels. |
|
| 62 * |
|
| 63 * Returns: TRUE if the pixbuf is opaque around the edges, FALSE otherwise |
|
| 64 */ |
|
| 65 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf); |
|
| 66 |
|
| 67 /** |
|
| 68 * pidgin_pixbuf_from_data: |
|
| 69 * @buf: The raw binary image data. |
|
| 70 * @count: The length of buf in bytes. |
|
| 71 * |
|
| 72 * Create a GdkPixbuf from a chunk of image data. |
|
| 73 * |
|
| 74 * Returns: (transfer full): A GdkPixbuf created from the image data, or NULL if |
|
| 75 * there was an error parsing the data. |
|
| 76 */ |
|
| 77 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count); |
|
| 78 |
|
| 79 /** |
|
| 80 * pidgin_pixbuf_anim_from_data: |
|
| 81 * @buf: The raw binary image data. |
|
| 82 * @count: The length of buf in bytes. |
|
| 83 * |
|
| 84 * Create a GdkPixbufAnimation from a chunk of image data. |
|
| 85 * |
|
| 86 * Returns: (transfer full): A GdkPixbufAnimation created from the image data, or NULL if |
|
| 87 * there was an error parsing the data. |
|
| 88 */ |
|
| 89 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count); |
|
| 90 |
|
| 91 /** |
|
| 92 * pidgin_pixbuf_from_image: |
|
| 93 * @image: a PurpleImage. |
|
| 94 * |
|
| 95 * Create a GdkPixbuf from a PurpleImage. |
|
| 96 * |
|
| 97 * Returns: (transfer full): a GdkPixbuf created from the @image. |
|
| 98 */ |
|
| 99 GdkPixbuf * |
|
| 100 pidgin_pixbuf_from_image(PurpleImage *image); |
|
| 101 |
|
| 102 /** |
|
| 103 * pidgin_pixbuf_new_from_file: |
|
| 104 * @filename: Name of file to load, in the GLib file name encoding |
|
| 105 * |
|
| 106 * Helper function that calls gdk_pixbuf_new_from_file() and checks both |
|
| 107 * the return code and the GError and returns NULL if either one failed. |
|
| 108 * |
|
| 109 * The gdk-pixbuf documentation implies that it is sufficient to check |
|
| 110 * the return value of gdk_pixbuf_new_from_file() to determine |
|
| 111 * whether the image was able to be loaded. However, this is not the case |
|
| 112 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some |
|
| 113 * cases a GdkPixbuf object is returned that will cause some operations |
|
| 114 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an |
|
| 115 * infinite loop. |
|
| 116 * |
|
| 117 * This function shouldn't be necessary once Pidgin requires a version of |
|
| 118 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be |
|
| 119 * nice to keep this function around for the debug message that it logs. |
|
| 120 * |
|
| 121 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and |
|
| 122 * a warning is logged. |
|
| 123 */ |
|
| 124 GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename); |
|
| 125 |
|
| 126 /** |
|
| 127 * pidgin_pixbuf_new_from_file_at_size: |
|
| 128 * @filename: Name of file to load, in the GLib file name encoding |
|
| 129 * @width: The width the image should have or -1 to not constrain the width |
|
| 130 * @height: The height the image should have or -1 to not constrain the height |
|
| 131 * |
|
| 132 * Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks |
|
| 133 * both the return code and the GError and returns NULL if either one failed. |
|
| 134 * |
|
| 135 * The gdk-pixbuf documentation implies that it is sufficient to check |
|
| 136 * the return value of gdk_pixbuf_new_from_file_at_size() to determine |
|
| 137 * whether the image was able to be loaded. However, this is not the case |
|
| 138 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some |
|
| 139 * cases a GdkPixbuf object is returned that will cause some operations |
|
| 140 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an |
|
| 141 * infinite loop. |
|
| 142 * |
|
| 143 * This function shouldn't be necessary once Pidgin requires a version of |
|
| 144 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be |
|
| 145 * nice to keep this function around for the debug message that it logs. |
|
| 146 * |
|
| 147 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and |
|
| 148 * a warning is logged. |
|
| 149 */ |
|
| 150 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height); |
|
| 151 |
|
| 152 /** |
|
| 153 * pidgin_pixbuf_new_from_file_at_scale: |
|
| 154 * @filename: Name of file to load, in the GLib file name encoding |
|
| 155 * @width: The width the image should have or -1 to not constrain the width |
|
| 156 * @height: The height the image should have or -1 to not constrain the height |
|
| 157 * @preserve_aspect_ratio: TRUE to preserve the image's aspect ratio |
|
| 158 * |
|
| 159 * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks |
|
| 160 * both the return code and the GError and returns NULL if either one failed. |
|
| 161 * |
|
| 162 * The gdk-pixbuf documentation implies that it is sufficient to check |
|
| 163 * the return value of gdk_pixbuf_new_from_file_at_scale() to determine |
|
| 164 * whether the image was able to be loaded. However, this is not the case |
|
| 165 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some |
|
| 166 * cases a GdkPixbuf object is returned that will cause some operations |
|
| 167 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an |
|
| 168 * infinite loop. |
|
| 169 * |
|
| 170 * This function shouldn't be necessary once Pidgin requires a version of |
|
| 171 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be |
|
| 172 * nice to keep this function around for the debug message that it logs. |
|
| 173 * |
|
| 174 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and |
|
| 175 * a warning is logged. |
|
| 176 */ |
|
| 177 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio); |
|
| 178 |
|
| 179 /** |
|
| 180 * pidgin_pixbuf_scale_down: |
|
| 181 * @src: The source image. |
|
| 182 * @max_width: Maximum width in px. |
|
| 183 * @max_height: Maximum height in px. |
|
| 184 * @interp_type: Interpolation method. |
|
| 185 * @preserve_ratio: %TRUE to preserve image's aspect ratio. |
|
| 186 * |
|
| 187 * Scales the image to the desired dimensions. If image is smaller, it will be |
|
| 188 * returned without modifications. |
|
| 189 * |
|
| 190 * If new image is created, @src reference count will be decreased and new image |
|
| 191 * with a ref count of 1 will be returned. |
|
| 192 * |
|
| 193 * Returns: (transfer full): The image with proper sizing. %NULL in case of error. |
|
| 194 */ |
|
| 195 GdkPixbuf * |
|
| 196 pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height, |
|
| 197 GdkInterpType interp_type, gboolean preserve_ratio); |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 G_END_DECLS |
|
| 202 |
|
| 203 #endif /* PIDGIN_GDK_PIXBUF_H */ |
|