1 /* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "art_rgb_pixbuf_affine.h"
25 #include "art_point.h"
26 #include "art_affine.h"
27 #include "art_pixbuf.h"
28 #include "art_rgb_affine.h"
29 #include "art_rgb_affine.h"
30 #include "art_rgb_rgba_affine.h"
32 /* This module handles compositing of affine-transformed generic
33 pixbuf images over rgb pixel buffers. */
35 /* Composite the source image over the destination image, applying the
38 * art_rgb_pixbuf_affine: Affine transform source RGB pixbuf and composite.
39 * @dst: Destination image RGB buffer.
40 * @x0: Left coordinate of destination rectangle.
41 * @y0: Top coordinate of destination rectangle.
42 * @x1: Right coordinate of destination rectangle.
43 * @y1: Bottom coordinate of destination rectangle.
44 * @dst_rowstride: Rowstride of @dst buffer.
45 * @pixbuf: source image pixbuf.
46 * @affine: Affine transform.
47 * @level: Filter level.
48 * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing.
50 * Affine transform the source image stored in @src, compositing over
51 * the area of destination image @dst specified by the rectangle
52 * (@x0, @y0) - (@x1, @y1). As usual in libart, the left and top edges
53 * of this rectangle are included, and the right and bottom edges are
56 * The @alphagamma parameter specifies that the alpha compositing be
57 * done in a gamma-corrected color space. In the current
58 * implementation, it is ignored.
60 * The @level parameter specifies the speed/quality tradeoff of the
61 * image interpolation. Currently, only ART_FILTER_NEAREST is
65 art_rgb_pixbuf_affine (art_u8 *dst,
66 int x0, int y0, int x1, int y1, int dst_rowstride,
67 const ArtPixBuf *pixbuf,
68 const double affine[6],
70 ArtAlphaGamma *alphagamma)
72 if (pixbuf->format != ART_PIX_RGB)
74 art_warn ("art_rgb_pixbuf_affine: need RGB format image\n");
78 if (pixbuf->bits_per_sample != 8)
80 art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
84 if (pixbuf->n_channels != 3 + (pixbuf->has_alpha != 0))
86 art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
90 if (pixbuf->has_alpha)
91 art_rgb_rgba_affine (dst, x0, y0, x1, y1, dst_rowstride,
93 pixbuf->width, pixbuf->height, pixbuf->rowstride,
98 art_rgb_affine (dst, x0, y0, x1, y1, dst_rowstride,
100 pixbuf->width, pixbuf->height, pixbuf->rowstride,