* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-alias.h"
#include <string.h>
GdkPixbuf *new_pixbuf;
int x, y;
- g_return_val_if_fail (pixbuf != NULL, NULL);
+ g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4, NULL);
g_return_val_if_fail (pixbuf->bits_per_sample == 8, NULL);
*
* Copies a rectangular area from @src_pixbuf to @dest_pixbuf. Conversion of
* pixbuf formats is done automatically.
+ *
+ * If the source rectangle overlaps the destination rectangle on the
+ * same pixbuf, it will be overwritten during the copy operation.
+ * Therefore, you can not use this function to scroll a pixbuf.
**/
void
gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
* @saturation: saturation factor
* @pixelate: whether to pixelate
*
- * Modifies saturation and optionally pixelates @src, placing the
- * result in @dest. @src and @dest may be the same pixbuf with no ill
- * effects. If @saturation is 1.0 then saturation is not changed. If
- * it's less than 1.0, saturation is reduced (the image is darkened);
- * if greater than 1.0, saturation is increased (the image is
- * brightened). If @pixelate is %TRUE, then pixels are faded in a
- * checkerboard pattern to create a pixelated image. @src and @dest
- * must have the same image format, size, and rowstride.
+ * Modifies saturation and optionally pixelates @src, placing the result in
+ * @dest. @src and @dest may be the same pixbuf with no ill effects. If
+ * @saturation is 1.0 then saturation is not changed. If it's less than 1.0,
+ * saturation is reduced (the image turns toward grayscale); if greater than
+ * 1.0, saturation is increased (the image gets more vivid colors). If @pixelate
+ * is %TRUE, then pixels are faded in a checkerboard pattern to create a
+ * pixelated image. @src and @dest must have the same image format, size, and
+ * rowstride.
*
**/
void
if (saturation == 1.0 && !pixelate) {
if (dest != src)
- memcpy (gdk_pixbuf_get_pixels (dest),
- gdk_pixbuf_get_pixels (src),
- gdk_pixbuf_get_height (src) * gdk_pixbuf_get_rowstride (src));
+ gdk_pixbuf_copy_area (src, 0, 0,
+ gdk_pixbuf_get_width (src),
+ gdk_pixbuf_get_height (src),
+ dest, 0, 0);
} else {
int i, j, t;
int width, height, has_alpha, src_rowstride, dest_rowstride, bytes_per_pixel;
}
}
+
+/**
+ * gdk_pixbuf_apply_embedded_orientation:
+ * @src: A #GdkPixbuf.
+ *
+ * Takes an existing pixbuf and checks for the presence of an
+ * associated "orientation" option, which may be provided by the
+ * jpeg loader (which reads the exif orientation tag) or the
+ * tiff loader (which reads the tiff orientation tag, and
+ * compensates it for the partial transforms performed by
+ * libtiff). If an orientation option/tag is present, the
+ * appropriate transform will be performed so that the pixbuf
+ * is oriented correctly.
+ *
+ * Return value: A newly-created pixbuf, or a reference to the
+ * input pixbuf (with an increased reference count).
+ *
+ * Since 2.12
+ **/
+GdkPixbuf *
+gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src)
+{
+ const gchar *orientation_string;
+ int transform = 0;
+ GdkPixbuf *temp;
+ GdkPixbuf *dest;
+
+ g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
+
+ /* Read the orientation option associated with the pixbuf */
+ orientation_string = gdk_pixbuf_get_option (src, "orientation");
+
+ if (orientation_string) {
+ /* If an orientation option was found, convert the
+ orientation string into an integer. */
+ transform = (int) g_ascii_strtoll (orientation_string, NULL, 10);
+ }
+
+ /* Apply the actual transforms, which involve rotations and flips.
+ The meaning of orientation values 1-8 and the required transforms
+ are defined by the TIFF and EXIF (for JPEGs) standards. */
+ switch (transform) {
+ case 1:
+ dest = src;
+ g_object_ref (dest);
+ break;
+ case 2:
+ dest = gdk_pixbuf_flip (src, TRUE);
+ break;
+ case 3:
+ dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_UPSIDEDOWN);
+ break;
+ case 4:
+ dest = gdk_pixbuf_flip (src, FALSE);
+ break;
+ case 5:
+ temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+ dest = gdk_pixbuf_flip (temp, TRUE);
+ g_object_unref (temp);
+ break;
+ case 6:
+ dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+ break;
+ case 7:
+ temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
+ dest = gdk_pixbuf_flip (temp, FALSE);
+ g_object_unref (temp);
+ break;
+ case 8:
+ dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
+ break;
+ default:
+ /* if no orientation tag was present */
+ dest = src;
+ g_object_ref (dest);
+ break;
+ }
+
+ return dest;
+}
+
+
#define __GDK_PIXBUF_UTIL_C__
#include "gdk-pixbuf-aliasdef.c"