source: trunk/third/libart_lgpl/art_rgb_pixbuf_affine.c @ 18256

Revision 18256, 3.4 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18255, which included commits to RCS files with non-trunk default branches.
Line 
1/* Libart_LGPL - library of basic graphic primitives
2 * Copyright (C) 1998 Raph Levien
3 *
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.
8 *
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.
13 *
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.
18 */
19
20#include "config.h"
21#include "art_rgb_pixbuf_affine.h"
22
23#include <math.h>
24#include "art_misc.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"
31
32/* This module handles compositing of affine-transformed generic
33   pixbuf images over rgb pixel buffers. */
34
35/* Composite the source image over the destination image, applying the
36   affine transform. */
37/**
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.
49 *
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
54 * excluded.
55 *
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.
59 *
60 * The @level parameter specifies the speed/quality tradeoff of the
61 * image interpolation. Currently, only ART_FILTER_NEAREST is
62 * implemented.
63 **/
64void
65art_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],
69                       ArtFilterLevel level,
70                       ArtAlphaGamma *alphagamma)
71{
72  if (pixbuf->format != ART_PIX_RGB)
73    {
74      art_warn ("art_rgb_pixbuf_affine: need RGB format image\n");
75      return;
76    }
77
78  if (pixbuf->bits_per_sample != 8)
79    {
80      art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
81      return;
82    }
83
84  if (pixbuf->n_channels != 3 + (pixbuf->has_alpha != 0))
85    {
86      art_warn ("art_rgb_pixbuf_affine: need 8-bit sample data\n");
87      return;
88    }
89
90  if (pixbuf->has_alpha)
91    art_rgb_rgba_affine (dst, x0, y0, x1, y1, dst_rowstride,
92                         pixbuf->pixels,
93                         pixbuf->width, pixbuf->height, pixbuf->rowstride,
94                         affine,
95                         level,
96                         alphagamma);
97  else
98    art_rgb_affine (dst, x0, y0, x1, y1, dst_rowstride,
99                    pixbuf->pixels,
100                    pixbuf->width, pixbuf->height, pixbuf->rowstride,
101                    affine,
102                    level,
103                    alphagamma);
104}
Note: See TracBrowser for help on using the repository browser.