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.
22 #include "art_point.h"
23 #include "art_affine.h"
24 #include "art_pixbuf.h"
25 #include "art_rgb_affine.h"
26 #include "art_rgb_affine.h"
27 #include "art_rgb_rgba_affine.h"
28 #include "art_rgb_pixbuf_affine.h"
30 /* This module handles compositing of affine-transformed generic
31 pixbuf images over rgb pixel buffers. */
33 /* Composite the source image over the destination image, applying the
36 * art_rgb_pixbuf_affine: Affine transform source RGB pixbuf and composite.
37 * @dst: Destination image RGB buffer.
38 * @x0: Left coordinate of destination rectangle.
39 * @y0: Top coordinate of destination rectangle.
40 * @x1: Right coordinate of destination rectangle.
41 * @y1: Bottom coordinate of destination rectangle.
42 * @dst_rowstride: Rowstride of @dst buffer.
43 * @pixbuf: source image pixbuf.
44 * @affine: Affine transform.
45 * @level: Filter level.
46 * @alphagamma: #ArtAlphaGamma for gamma-correcting the compositing.
48 * Affine transform the source image stored in @src, compositing over
49 * the area of destination image @dst specified by the rectangle
50 * (@x0, @y0) - (@x1, @y1). As usual in libart, the left and top edges
51 * of this rectangle are included, and the right and bottom edges are
54 * The @alphagamma parameter specifies that the alpha compositing be
55 * done in a gamma-corrected color space. In the current
56 * implementation, it is ignored.
58 * The @level parameter specifies the speed/quality tradeoff of the
59 * image interpolation. Currently, only ART_FILTER_NEAREST is
63 art_rgb_pixbuf_affine (art_u8 *dst,
64 int x0, int y0, int x1, int y1, int dst_rowstride,
65 const ArtPixBuf *pixbuf,
66 const double affine[6],
68 ArtAlphaGamma *alphagamma)
70 if (pixbuf->format != ART_PIX_RGB)
72 art_warn ("art_rgb_pixbuf_affine: need RGB format image\n");
76 if (pixbuf->bits_per_sample != 8)
78 art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
82 if (pixbuf->n_channels != 3 + (pixbuf->has_alpha != 0))
84 art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
88 if (pixbuf->has_alpha)
89 art_rgb_rgba_affine (dst, x0, y0, x1, y1, dst_rowstride,
91 pixbuf->width, pixbuf->height, pixbuf->rowstride,
96 art_rgb_affine (dst, x0, y0, x1, y1, dst_rowstride,
98 pixbuf->width, pixbuf->height, pixbuf->rowstride,