diff -r 9454cc5cd5fb -r 0604c6839974 libpurple/purpleimage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/purpleimage.h Thu Aug 07 21:32:18 2025 -0500 @@ -0,0 +1,163 @@ +/* + * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this library; if not, see . + */ + +#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) +# error "only may be included directly" +#endif + +#ifndef PURPLE_IMAGE_H +#define PURPLE_IMAGE_H + +#include + +#include "purpleversion.h" + + +G_BEGIN_DECLS + +#define PURPLE_TYPE_IMAGE (purple_image_get_type()) + +/** + * PurpleImage: + * + * A container for raw image data. It doesn't manipulate the image data, it + * just stores it in its binary format - png, jpeg etc. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +G_DECLARE_FINAL_TYPE(PurpleImage, purple_image, PURPLE, IMAGE, GObject) + +/** + * purple_image_get_contents: + * + * Gets the contents of the image. + * + * Returns: (transfer none): The contents. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +GBytes *purple_image_get_contents(PurpleImage *image); + +/** + * purple_image_get_data: + * @size: (out) (nullable): a return address for the length of the data + * + * Gets the data of the image. + * + * Optionally the size can be returned as well via @size parameter. + * + * Returns: (transfer none): The data. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +gconstpointer purple_image_get_data(PurpleImage *image, gsize *size); + +/** + * purple_image_get_filename: + * + * Gets the filename to the image + * + * Returns: (nullable): The filename of the image. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +const char *purple_image_get_filename(PurpleImage *image); + +/** + * purple_image_new_from_bytes: + * @bytes: (transfer none): the new image data + * + * Creates an image from bytes. + * + * Returns: (transfer full): The new instance. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +PurpleImage *purple_image_new_from_bytes(GBytes *bytes); + +/** + * purple_image_new_from_data: + * @data: (transfer none): the raw image data + * @size: the size of the raw image data + * + * Creates a new image from raw data. + * + * Returns: (transfer full): The new instance. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +PurpleImage *purple_image_new_from_data(gconstpointer data, gsize size); + +/** + * purple_image_new_from_filename: + * @filename: the filename of the image file + * @error: (out) (nullable): a return address for a #GError + * + * Creates an image from a file. + * + * The @filename must exist, be readable, and have valid image contents. + * + * Returns: (transfer full): The new instance. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +PurpleImage *purple_image_new_from_filename(const char *filename, GError **error); + +/** + * purple_image_new_from_resource: + * @path: the path of the resource + * @error: (out) (nullable): a return address for a #GError + * + * Creates a new image from a resource. + * + * Returns: (transfer full) (nullable): The new image on success; otherwise + * null with @error set. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +PurpleImage *purple_image_new_from_resource(const char *path, GError **error); + +/** + * purple_image_save: + * @filename: the filename to save to + * @error: (out) (nullable): a return address for a #GError + * + * Saves an @image to the disk. + * + * Returns: %TRUE if succeeded, %FALSE otherwise. + * + * Since: 3.0 + */ +PURPLE_AVAILABLE_IN_3_0 +gboolean purple_image_save(PurpleImage *image, const char *filename, GError **error); + +G_END_DECLS + +#endif /* PURPLE_IMAGE_H */