|
|
@@ -82,7 +82,7 @@ int pipi_draw_line(pipi_image_t *img , int x1, int y1, int x2, int y2, uint32_t |
|
|
|
dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels; |
|
|
|
s.color32 = c; |
|
|
|
s.buf_u32 = dstdata; |
|
|
|
s.draw = aliased_line_8bit; |
|
|
|
s.draw = line_8bit; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@@ -92,7 +92,7 @@ int pipi_draw_line(pipi_image_t *img , int x1, int y1, int x2, int y2, uint32_t |
|
|
|
s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = antialiased_line; |
|
|
|
s.draw = aaline; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(img->last_modified == PIPI_PIXELS_Y_F) |
|
|
@@ -101,7 +101,7 @@ int pipi_draw_line(pipi_image_t *img , int x1, int y1, int x2, int y2, uint32_t |
|
|
|
dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_Y_F)->pixels; |
|
|
|
s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray; |
|
|
|
s.draw = aa ? aaline_gray : line_gray; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@@ -111,69 +111,21 @@ int pipi_draw_line(pipi_image_t *img , int x1, int y1, int x2, int y2, uint32_t |
|
|
|
s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = aa == 0 ? aliased_line : antialiased_line; |
|
|
|
s.draw = aa ? aaline : line; |
|
|
|
} |
|
|
|
|
|
|
|
clip_line(img, &s); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int pipi_draw_polyline(pipi_image_t *img, int const x[], int const y[], |
|
|
|
int n, uint32_t c, int aa) |
|
|
|
{ |
|
|
|
int i; |
|
|
|
struct line s; |
|
|
|
|
|
|
|
if(img->last_modified == PIPI_PIXELS_RGBA_C) |
|
|
|
{ |
|
|
|
if(!aa) |
|
|
|
{ |
|
|
|
uint32_t *dstdata; |
|
|
|
dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels; |
|
|
|
s.color32 = c; |
|
|
|
s.buf_u32 = dstdata; |
|
|
|
s.draw = aliased_line_8bit; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
float *dstdata; |
|
|
|
dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels; |
|
|
|
s.colorf[2] = ((c&0x00FF0000)>>16)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[0] = (c&0x000000FF)/255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = antialiased_line; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(img->last_modified == PIPI_PIXELS_Y_F) |
|
|
|
{ |
|
|
|
float *dstdata; |
|
|
|
dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_Y_F)->pixels; |
|
|
|
s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
float *dstdata; |
|
|
|
dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels; |
|
|
|
s.colorf[0] = (c&0x00FF0000)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[1] = (c&0x0000FF00)/255.0f; /* XXX FIXME */ |
|
|
|
s.colorf[2] = (c&0x000000FF)/255.0f; /* XXX FIXME */ |
|
|
|
s.buf_f = dstdata; |
|
|
|
s.draw = aa == 0 ? aliased_line : antialiased_line; |
|
|
|
img->last_modified = PIPI_PIXELS_RGBA_F; |
|
|
|
} |
|
|
|
|
|
|
|
for(i = 0; i < n; i++) |
|
|
|
{ |
|
|
|
s.x1 = x[i]; |
|
|
|
s.y1 = y[i]; |
|
|
|
s.x2 = x[i+1]; |
|
|
|
s.y2 = y[i+1]; |
|
|
|
clip_line(img, &s); |
|
|
|
} |
|
|
|
pipi_draw_line(img, x[i], y[i], x[i + 1], y[i + 1], c, aa); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
@@ -255,13 +207,13 @@ static uint8_t clip_bits(pipi_image_t *img, int x, int y) |
|
|
|
/* Xiaolin Wu's line algorithm, as seen at http://portal.acm.org/citation.cfm?id=122734 */ |
|
|
|
|
|
|
|
#define PLOT(x, y, c) \ |
|
|
|
if(FLAG_GRAY) \ |
|
|
|
if(FLAG_8BIT) \ |
|
|
|
{ \ |
|
|
|
if(FLAG_8BIT) \ |
|
|
|
{ \ |
|
|
|
/* TODO */ \ |
|
|
|
} \ |
|
|
|
else \ |
|
|
|
/* TODO */ \ |
|
|
|
} \ |
|
|
|
else \ |
|
|
|
{ \ |
|
|
|
if(FLAG_GRAY) \ |
|
|
|
{ \ |
|
|
|
s->buf_f[((int)(x))+((int)(y))*img->w] = \ |
|
|
|
(c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w]; \ |
|
|
@@ -269,40 +221,25 @@ static uint8_t clip_bits(pipi_image_t *img, int x, int y) |
|
|
|
s->buf_f[((int)(x))+((int)(y))*img->w] = 1.0f; \ |
|
|
|
if(s->buf_f[((int)(x))+((int)(y))*img->w] < 0.0f) \ |
|
|
|
s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \ |
|
|
|
if(isnan(s->buf_f[((int)(x))+((int)(y))*img->w])) \ |
|
|
|
s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
else \ |
|
|
|
{ \ |
|
|
|
if(FLAG_8BIT) \ |
|
|
|
{ \ |
|
|
|
/* TODO */ \ |
|
|
|
} \ |
|
|
|
else \ |
|
|
|
{ \ |
|
|
|
{ \ |
|
|
|
int qwer = (((int)(x)*4))+((int)(y))*(img->w*4);\ |
|
|
|
int qweg = (1+((int)(x)*4))+((int)(y))*(img->w*4); \ |
|
|
|
int qweb = (2+((int)(x)*4))+((int)(y))*(img->w*4); \ |
|
|
|
s->buf_f[qwer] = (c*s->colorf[0]) + (1-c) * s->buf_f[qwer]; \ |
|
|
|
s->buf_f[qweg] = (c*s->colorf[1]) + (1-c) * s->buf_f[qweg]; \ |
|
|
|
s->buf_f[qweb] = (c*s->colorf[2]) + (1-c) * s->buf_f[qweb]; \ |
|
|
|
if(s->buf_f[qwer] > 1.0f) \ |
|
|
|
s->buf_f[qwer] = 1.0f; \ |
|
|
|
if(s->buf_f[qwer] < 0.0f || isnan(s->buf_f[qwer])) \ |
|
|
|
s->buf_f[qwer] = 0.0f; \ |
|
|
|
if(s->buf_f[qweg] > 1.0f) \ |
|
|
|
s->buf_f[qweg] = 1.0f; \ |
|
|
|
if(s->buf_f[qweg] < 0.0f || isnan(s->buf_f[qweg])) \ |
|
|
|
s->buf_f[qweg] = 0.0f; \ |
|
|
|
if(s->buf_f[qweb] > 1.0f) \ |
|
|
|
s->buf_f[qweb] = 1.0f; \ |
|
|
|
if(s->buf_f[qweb] < 0.0f || isnan(s->buf_f[qweb])) \ |
|
|
|
s->buf_f[qweb] = 0.0f; \ |
|
|
|
if(s->buf_f[qwer] > 1.0f) s->buf_f[qwer] = 1.0f; \ |
|
|
|
if(s->buf_f[qwer] < 0.0f) s->buf_f[qwer] = 0.0f; \ |
|
|
|
if(s->buf_f[qweg] > 1.0f) s->buf_f[qweg] = 1.0f; \ |
|
|
|
if(s->buf_f[qweg] < 0.0f) s->buf_f[qweg] = 0.0f; \ |
|
|
|
if(s->buf_f[qweb] > 1.0f) s->buf_f[qweb] = 1.0f; \ |
|
|
|
if(s->buf_f[qweb] < 0.0f) s->buf_f[qweb] = 0.0f; \ |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
static void SUFFIX(antialiased_line)(pipi_image_t *img, struct line* s) |
|
|
|
static void SUFFIX(aaline)(pipi_image_t *img, struct line* s) |
|
|
|
{ |
|
|
|
float x1 = s->x1, y1 = s->y1, x2 = s->x2, y2 = s->y2; |
|
|
|
float g, xd, yd, xgap, xend, yend, xf, yf, val1, val2; |
|
|
@@ -423,7 +360,7 @@ static void SUFFIX(antialiased_line)(pipi_image_t *img, struct line* s) |
|
|
|
|
|
|
|
/* Solid line drawing function, using Bresenham's mid-point line |
|
|
|
* scan-conversion algorithm. */ |
|
|
|
static void SUFFIX(aliased_line)(pipi_image_t *img, struct line* s) |
|
|
|
static void SUFFIX(line)(pipi_image_t *img, struct line* s) |
|
|
|
{ |
|
|
|
int x1, y1, x2, y2; |
|
|
|
int dx, dy; |
|
|
|