Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Functions
art_rgb_svp.h File Reference
#include <libart_lgpl/art_alphagamma.h>
#include <libart_lgpl/art_svp.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void art_rgb_svp_aa_ (const ArtSVP *svp, int x0, int y0, int x1, int y1, art_u32 fg_color, art_u32 bg_color, art_u8 *buf, int rowstride, ArtAlphaGamma *alphagamma)
 art_rgb_svp_aa: Render sorted vector path into RGB buffer.
void art_rgb_svp_alpha_ (const ArtSVP *svp, int x0, int y0, int x1, int y1, art_u32 rgb, int alpha, art_u8 *buf, int rowstride, ArtAlphaGamma *alphagamma)
 art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer.

Function Documentation

void art_rgb_svp_aa_ ( const ArtSVP *  svp,
int  x0,
int  y0,
int  x1,
int  y1,
art_u32  fg_color,
art_u32  bg_color,
art_u8 *  buf,
int  rowstride,
ArtAlphaGamma *  alphagamma 
)

art_rgb_svp_aa: Render sorted vector path into RGB buffer.

: The source sorted vector path. : Left coordinate of destination rectangle. : Top coordinate of destination rectangle. : Right coordinate of destination rectangle. : Bottom coordinate of destination rectangle. : Foreground color in 0xRRGGBB format. : Background color in 0xRRGGBB format. : Destination RGB buffer. : Rowstride of buffer. : #ArtAlphaGamma for gamma-correcting the rendering.

Renders the shape specified with into the RGB buffer. - specifies the width, and - specifies the height, of the rectangle rendered. The new pixels are stored starting at the first byte of . Thus, the and parameters specify an offset within , and may be tweaked as a way of doing integer-pixel translations without fiddling with itself.

The and arguments specify the opaque colors to be used for rendering. For pixels of entirely 0 winding-number, is used. For pixels of entirely 1 winding number, is used. In between, the color is interpolated based on the fraction of the pixel with a winding number of 1. If is NULL, then linear interpolation (in pixel counts) is the default. Otherwise, the interpolation is as specified by .

Definition at line 141 of file art_rgb_svp.c.

{
  ArtRgbSVPData data;

  int r_fg, g_fg, b_fg;
  int r_bg, g_bg, b_bg;
  int r, g, b;
  int dr, dg, db;
  int i;

  if (alphagamma == NULL)
    {
      r_fg = fg_color >> 16;
      g_fg = (fg_color >> 8) & 0xff;
      b_fg = fg_color & 0xff;

      r_bg = bg_color >> 16;
      g_bg = (bg_color >> 8) & 0xff;
      b_bg = bg_color & 0xff;

      r = (r_bg << 16) + 0x8000;
      g = (g_bg << 16) + 0x8000;
      b = (b_bg << 16) + 0x8000;
      dr = ((r_fg - r_bg) << 16) / 255;
      dg = ((g_fg - g_bg) << 16) / 255;
      db = ((b_fg - b_bg) << 16) / 255;

      for (i = 0; i < 256; i++)
       {
         data.rgbtab[i] = (r & 0xff0000) | ((g & 0xff0000) >> 8) | (b >> 16);
         r += dr;
         g += dg;
         b += db;
       }
    }
  else
    {
      int *table;
      art_u8 *invtab;

      table = alphagamma->table;

      r_fg = table[fg_color >> 16];
      g_fg = table[(fg_color >> 8) & 0xff];
      b_fg = table[fg_color & 0xff];

      r_bg = table[bg_color >> 16];
      g_bg = table[(bg_color >> 8) & 0xff];
      b_bg = table[bg_color & 0xff];

      r = (r_bg << 16) + 0x8000;
      g = (g_bg << 16) + 0x8000;
      b = (b_bg << 16) + 0x8000;
      dr = ((r_fg - r_bg) << 16) / 255;
      dg = ((g_fg - g_bg) << 16) / 255;
      db = ((b_fg - b_bg) << 16) / 255;

      invtab = alphagamma->invtable;
      for (i = 0; i < 256; i++)
       {
         data.rgbtab[i] = (invtab[r >> 16] << 16) |
           (invtab[g >> 16] << 8) |
           invtab[b >> 16];
         r += dr;
         g += dg;
         b += db;
       }
    }
  data.buf = buf;
  data.rowstride = rowstride;
  data.x0 = x0;
  data.x1 = x1;
  art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_callback_, &data);
}

Here is the call graph for this function:

void art_rgb_svp_alpha_ ( const ArtSVP *  svp,
int  x0,
int  y0,
int  x1,
int  y1,
art_u32  rgb,
int  alpha,
art_u8 *  buf,
int  rowstride,
ArtAlphaGamma *  alphagamma 
)

art_rgb_svp_alpha: Alpha-composite sorted vector path over RGB buffer.

: The source sorted vector path. : Left coordinate of destination rectangle. : Top coordinate of destination rectangle. : Right coordinate of destination rectangle. : Bottom coordinate of destination rectangle. : Color in 0xRRGGBBAA format. : Destination RGB buffer. : Rowstride of buffer. : #ArtAlphaGamma for gamma-correcting the compositing.

Renders the shape specified with over the RGB buffer. - specifies the width, and - specifies the height, of the rectangle rendered. The new pixels are stored starting at the first byte of . Thus, the and parameters specify an offset within , and may be tweaked as a way of doing integer-pixel translations without fiddling with itself.

The argument specifies the color for the rendering. Pixels of entirely 0 winding number are left untouched. Pixels of entirely 1 winding number have the color composited over them (ie, are replaced by the red, green, blue components of if the alpha component is 0xff). Pixels of intermediate coverage are interpolated according to the rule in , or default to linear if is NULL.

Definition at line 420 of file art_rgb_svp.c.

{
  ArtRgbSVPAlphaData data;
  int r, g, b;
  int i;
  int a, da;

#ifdef WORDS_BIGENDIAN
  r = (rgb >> 8)  & 0xff;
  g = (rgb >> 16) & 0xff;
  b = (rgb >> 24) & 0xff;
#else
  r = (rgb >> 16) & 0xff;
  g = (rgb >> 8) & 0xff;
  b = rgb & 0xff;
#endif

  data.r = r;
  data.g = g;
  data.b = b;
  data.alpha = alpha;
  data.rgb = rgb;

  a = 0x8000;
  da = (alpha * 66051 + 0x80) >> 8; /* 66051 equals 2 ^ 32 / (255 * 255) */

  for (i = 0; i < 256; i++)
    {
      data.alphatab[i] = a >> 16;
      a += da;
    }

  data.buf = buf;
  data.rowstride = rowstride;
  data.x0 = x0;
  data.x1 = x1;
  if (alpha == 255)
    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_alpha_opaque_callback_,
                     &data);
  else
    art_svp_render_aa (svp, x0, y0, x1, y1, art_rgb_svp_alpha_callback_, &data);
}

Here is the call graph for this function: