Changeset 2778 for libpipi


Ignore:
Timestamp:
Aug 27, 2008, 1:28:48 PM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Moved *line_template.c to .h files to avoid problems with autotools (sam)
  • Added antialiasing support to polylines
  • Ho, and previous commit (r2777) contains width/height/pitch accessors to pipi_image_t, too. LOL.
Location:
libpipi/trunk/pipi
Files:
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/paint/line.c

    r2777 r2778  
    109109
    110110int pipi_draw_polyline(pipi_image_t *img, int const x[], int const y[],
    111                        int n, uint32_t c)
     111                       int n, uint32_t c, int aa)
    112112{
    113113    int i;
     
    116116    if(img->last_modified == PIPI_PIXELS_RGBA_C)
    117117    {
    118         uint32_t  *dstdata;
    119         dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels;
    120         s.color32 = c;
    121         s.buf_u32 = dstdata;
    122         s.draw = draw_aliased_line_u32;
     118        if(!aa)
     119        {
     120            uint32_t  *dstdata;
     121            dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels;
     122            s.color32 = c;
     123            s.buf_u32 = dstdata;
     124            s.draw = draw_aliased_line_u32;
     125        }
     126        else
     127        {
     128            float  *dstdata;
     129            dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels;
     130            s.colorf[2] = ((c&0x00FF0000)>>16)/255.0f; /* XXX FIXME */
     131            s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f;  /* XXX FIXME */
     132            s.colorf[0] = (c&0x000000FF)/255.0f;       /* XXX FIXME */
     133            s.buf_f = dstdata;
     134            s.draw = draw_antialiased_line_float;
     135        }
     136    }
     137    else if(img->last_modified == PIPI_PIXELS_Y_F)
     138    {
     139        float  *dstdata;
     140        dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_Y_F)->pixels;
     141        s.colorf[0] = c/255.0f; /* XXX FIXME */
     142        s.buf_f = dstdata;
     143        s.draw = aa==0?draw_aliased_line_gray:draw_antialiased_line_gray;
    123144    }
    124145    else
     
    130151        s.colorf[2] = (c&0x000000FF)/255.0f; /* XXX FIXME */
    131152        s.buf_f = dstdata;
    132         s.draw = draw_aliased_line_float;
     153        s.draw = aa==0?draw_aliased_line_float:draw_antialiased_line_float;
    133154        img->last_modified = PIPI_PIXELS_RGBA_F;
    134155    }
     
    229250#undef  ASSIGN
    230251#define ASSIGN(x, y, w) s->buf_u32[x+y*w] = s->color32;
    231 #include "line_template.c"
     252#include "line_template.h"
    232253}
    233254static void draw_aliased_line_float(pipi_image_t *img, struct line* s)
     
    237258                         s->buf_f[1 + (x*4)+y*(w*4)] = s->colorf[1]; \
    238259                         s->buf_f[2 + (x*4)+y*(w*4)] = s->colorf[2];
    239 #include "line_template.c"
     260#include "line_template.h"
    240261}
    241262static void draw_aliased_line_gray(pipi_image_t *img, struct line* s)
     
    243264#undef  ASSIGN
    244265#define ASSIGN(x, y, w) s->buf_f[x+y*w]     = s->colorf[0];
    245 #include "line_template.c"
     266#include "line_template.h"
    246267}
    247268
     
    266287    s->buf_f[(2+((int)(x)*4))+((int)(y))*(img->w*4)] = \
    267288        (c*s->colorf[2]) + (1-c) * s->buf_f[(2+((int)(x)*4))+((int)(y))*(img->w*4)];
    268 #include "aline_template.c"
     289#include "aline_template.h"
    269290}
    270291
     
    275296#define PLOT(x, y, c) s->buf_f[((int)(x))+((int)(y))*img->w] =  \
    276297    (c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w];
    277 #include "aline_template.c"
    278 }
     298#include "aline_template.h"
     299}
  • libpipi/trunk/pipi/pipi.h

    r2777 r2778  
    156156extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int);
    157157extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[],
    158                               int , uint32_t);
     158                              int , uint32_t, int);
    159159extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *);
    160160
Note: See TracChangeset for help on using the changeset viewer.