Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Defines | Functions
art_rgb_affine_private.c File Reference
#include "scconfig.h"
#include "art_rgb_affine_private.h"
#include <math.h>
#include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_point.h>
#include <libart_lgpl/art_affine.h>

Go to the source code of this file.

Defines

#define EPSILON   1e-6

Functions

void art_rgb_affine_run (int *p_x0, int *p_x1, int y, int src_width, int src_height, const double affine[6])

Define Documentation

#define EPSILON   1e-6

Definition at line 41 of file art_rgb_affine_private.c.


Function Documentation

void art_rgb_affine_run ( int p_x0,
int p_x1,
int  y,
int  src_width,
int  src_height,
const double  affine[6] 
)

Definition at line 44 of file art_rgb_affine_private.c.

{
  int x0, x1;
  double z;
  double x_intercept;
  int xi;

  x0 = *p_x0;
  x1 = *p_x1;

  /* do left and right edges */
  if (affine[0] > EPSILON)
    {
      z = affine[2] * (y + 0.5) + affine[4];
      x_intercept = -z / affine[0];
      xi = ceil (x_intercept + EPSILON - 0.5);
      if (xi > x0)
       x0 = xi;
      x_intercept = (-z + src_width) / affine[0];
      xi = ceil (x_intercept - EPSILON - 0.5);
      if (xi < x1)
       x1 = xi;
    }
  else if (affine[0] < -EPSILON)
    {
      z = affine[2] * (y + 0.5) + affine[4];
      x_intercept = (-z + src_width) / affine[0];
      xi = ceil (x_intercept + EPSILON - 0.5);
      if (xi > x0)
       x0 = xi;
      x_intercept = -z / affine[0];
      xi = ceil (x_intercept - EPSILON - 0.5);
      if (xi < x1)
       x1 = xi;
    }
  else
    {
      z = affine[2] * (y + 0.5) + affine[4];
      if (z < 0 || z >= src_width)
       {
         *p_x1 = *p_x0;
         return;
       }
    }

  /* do top and bottom edges */
  if (affine[1] > EPSILON)
    {
      z = affine[3] * (y + 0.5) + affine[5];
      x_intercept = -z / affine[1];
      xi = ceil (x_intercept + EPSILON - 0.5);
      if (xi > x0)
       x0 = xi;
      x_intercept = (-z + src_height) / affine[1];
      xi = ceil (x_intercept - EPSILON - 0.5);
      if (xi < x1)
       x1 = xi;
    }
  else if (affine[1] < -EPSILON)
    {
      z = affine[3] * (y + 0.5) + affine[5];
      x_intercept = (-z + src_height) / affine[1];
      xi = ceil (x_intercept + EPSILON - 0.5);
      if (xi > x0)
       x0 = xi;
      x_intercept = -z / affine[1];
      xi = ceil (x_intercept - EPSILON - 0.5);
      if (xi < x1)
       x1 = xi;
    }
  else
    {
      z = affine[3] * (y + 0.5) + affine[5];
      if (z < 0 || z >= src_height)
       {
         *p_x1 = *p_x0;
         return;
       }
    }

  *p_x0 = x0;
  *p_x1 = x1;
}

Here is the caller graph for this function: