Back to index

scribus-ng  1.3.4.dfsg+svn20071115
art_rgba_affine.c
Go to the documentation of this file.
00001 /* Libart_LGPL - library of basic graphic primitives
00002  * Copyright (C) 1998 Raph Levien
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #include "scconfig.h"
00021 
00022 #include "art_rgba_affine.h"
00023 
00024 #include <math.h>
00025 #include <libart_lgpl/art_misc.h>
00026 #include <libart_lgpl/art_point.h>
00027 #include <libart_lgpl/art_affine.h>
00028 #include "art_rgb_affine_private.h"
00029 
00030 /* This module handles compositing of affine-transformed rgb images
00031    over rgb pixel buffers. */
00032 
00064 void
00065 art_rgba_affine (art_u8 *dst, int x0, int y0, int x1, int y1, int dst_rowstride,
00066               const art_u8 *src,
00067               int src_width, int src_height, int src_rowstride,
00068               const double affine[6],
00069               ArtFilterLevel level,
00070               ArtAlphaGamma *alphagamma)
00071 {
00072   /* Note: this is a slow implementation, and is missing all filter
00073      levels other than NEAREST. It is here for clarity of presentation
00074      and to establish the interface. */
00075   int x, y;
00076   double inv[6];
00077   art_u8 *dst_p, *dst_linestart;
00078   const art_u8 *src_p;
00079   ArtPoint pt, src_pt;
00080   int src_x, src_y;
00081   int run_x0, run_x1;
00082 
00083   dst_linestart = dst;
00084   art_affine_invert (inv, affine);
00085   for (y = y0; y < y1; y++)
00086     {
00087       pt.y = y + 0.5;
00088       run_x0 = x0;
00089       run_x1 = x1;
00090       art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height,
00091                        inv);
00092       dst_p = dst_linestart + (run_x0 - x0) * 4;
00093       for (x = run_x0; x < run_x1; x++)
00094        {
00095          pt.x = x + 0.5;
00096          art_affine_point (&src_pt, &pt, inv);
00097          src_x = floor (src_pt.x);
00098          src_y = floor (src_pt.y);
00099          src_p = src + (src_y * src_rowstride) + src_x * 4;
00100          dst_p[0] = src_p[0];
00101          dst_p[1] = src_p[1];
00102          dst_p[2] = src_p[2];
00103          dst_p[3] = src_p[3];
00104          dst_p += 4;
00105        }
00106       dst_linestart += dst_rowstride;
00107     }
00108 }