diff -r 8fa1f37d32f2 -r 910bdda75c74 pidgin/pidgingdkpixbuf.h --- a/pidgin/pidgingdkpixbuf.h Tue Oct 26 04:04:58 2021 -0500 +++ b/pidgin/pidgingdkpixbuf.h Tue Oct 26 04:05:39 2021 -0500 @@ -64,6 +64,140 @@ */ gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf); +/** + * pidgin_pixbuf_from_data: + * @buf: The raw binary image data. + * @count: The length of buf in bytes. + * + * Create a GdkPixbuf from a chunk of image data. + * + * Returns: (transfer full): A GdkPixbuf created from the image data, or NULL if + * there was an error parsing the data. + */ +GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count); + +/** + * pidgin_pixbuf_anim_from_data: + * @buf: The raw binary image data. + * @count: The length of buf in bytes. + * + * Create a GdkPixbufAnimation from a chunk of image data. + * + * Returns: (transfer full): A GdkPixbufAnimation created from the image data, or NULL if + * there was an error parsing the data. + */ +GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count); + +/** + * pidgin_pixbuf_from_image: + * @image: a PurpleImage. + * + * Create a GdkPixbuf from a PurpleImage. + * + * Returns: (transfer full): a GdkPixbuf created from the @image. + */ +GdkPixbuf * +pidgin_pixbuf_from_image(PurpleImage *image); + +/** + * pidgin_pixbuf_new_from_file: + * @filename: Name of file to load, in the GLib file name encoding + * + * Helper function that calls gdk_pixbuf_new_from_file() and checks both + * the return code and the GError and returns NULL if either one failed. + * + * The gdk-pixbuf documentation implies that it is sufficient to check + * the return value of gdk_pixbuf_new_from_file() to determine + * whether the image was able to be loaded. However, this is not the case + * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some + * cases a GdkPixbuf object is returned that will cause some operations + * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an + * infinite loop. + * + * This function shouldn't be necessary once Pidgin requires a version of + * gdk-pixbuf where the aforementioned bug is fixed. However, it might be + * nice to keep this function around for the debug message that it logs. + * + * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and + * a warning is logged. + */ +GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename); + +/** + * pidgin_pixbuf_new_from_file_at_size: + * @filename: Name of file to load, in the GLib file name encoding + * @width: The width the image should have or -1 to not constrain the width + * @height: The height the image should have or -1 to not constrain the height + * + * Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks + * both the return code and the GError and returns NULL if either one failed. + * + * The gdk-pixbuf documentation implies that it is sufficient to check + * the return value of gdk_pixbuf_new_from_file_at_size() to determine + * whether the image was able to be loaded. However, this is not the case + * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some + * cases a GdkPixbuf object is returned that will cause some operations + * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an + * infinite loop. + * + * This function shouldn't be necessary once Pidgin requires a version of + * gdk-pixbuf where the aforementioned bug is fixed. However, it might be + * nice to keep this function around for the debug message that it logs. + * + * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and + * a warning is logged. + */ +GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height); + +/** + * pidgin_pixbuf_new_from_file_at_scale: + * @filename: Name of file to load, in the GLib file name encoding + * @width: The width the image should have or -1 to not constrain the width + * @height: The height the image should have or -1 to not constrain the height + * @preserve_aspect_ratio: TRUE to preserve the image's aspect ratio + * + * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks + * both the return code and the GError and returns NULL if either one failed. + * + * The gdk-pixbuf documentation implies that it is sufficient to check + * the return value of gdk_pixbuf_new_from_file_at_scale() to determine + * whether the image was able to be loaded. However, this is not the case + * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some + * cases a GdkPixbuf object is returned that will cause some operations + * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an + * infinite loop. + * + * This function shouldn't be necessary once Pidgin requires a version of + * gdk-pixbuf where the aforementioned bug is fixed. However, it might be + * nice to keep this function around for the debug message that it logs. + * + * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and + * a warning is logged. + */ +GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio); + +/** + * pidgin_pixbuf_scale_down: + * @src: The source image. + * @max_width: Maximum width in px. + * @max_height: Maximum height in px. + * @interp_type: Interpolation method. + * @preserve_ratio: %TRUE to preserve image's aspect ratio. + * + * Scales the image to the desired dimensions. If image is smaller, it will be + * returned without modifications. + * + * If new image is created, @src reference count will be decreased and new image + * with a ref count of 1 will be returned. + * + * Returns: (transfer full): The image with proper sizing. %NULL in case of error. + */ +GdkPixbuf * +pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height, + GdkInterpType interp_type, gboolean preserve_ratio); + + + G_END_DECLS #endif /* PIDGIN_GDK_PIXBUF_H */