|
|
@@ -35,8 +35,8 @@ static void pipi_flood_fill_stack_scanline_u32(pipi_pixels_t *dstp, |
|
|
|
uint32_t new, uint32_t old); |
|
|
|
static void pipi_flood_fill_stack_scanline_float(pipi_pixels_t *dstp, |
|
|
|
int x, int y, |
|
|
|
float nr, float ng, float nb, |
|
|
|
float or, float og, float ob); |
|
|
|
float nr, float ng, float nb, float na, |
|
|
|
float or, float og, float ob, float oa); |
|
|
|
static int pop (int *x,int *y, int h); |
|
|
|
static int push(int x, int y, int h); |
|
|
|
static void clear_stack(int h); |
|
|
@@ -63,7 +63,7 @@ static int validate_pixel_f(float r1, float g1, float b1, |
|
|
|
/* Public function */ |
|
|
|
int pipi_flood_fill(pipi_image_t *src, |
|
|
|
int px, int py, |
|
|
|
float r, float g, float b) |
|
|
|
float r, float g, float b, float a) |
|
|
|
{ |
|
|
|
pipi_image_t *dst = src; |
|
|
|
pipi_pixels_t *dstp; |
|
|
@@ -80,7 +80,7 @@ int pipi_flood_fill(pipi_image_t *src, |
|
|
|
|
|
|
|
if(src->last_modified == PIPI_PIXELS_RGBA32) { |
|
|
|
uint32_t *dstdata; |
|
|
|
unsigned char nr, ng, nb; |
|
|
|
unsigned char nr, ng, nb, na; |
|
|
|
|
|
|
|
/* Get ARGB32 pointer */ |
|
|
|
dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA32); |
|
|
@@ -89,15 +89,16 @@ int pipi_flood_fill(pipi_image_t *src, |
|
|
|
nr = r*255.0f; |
|
|
|
ng = g*255.0f; |
|
|
|
nb = b*255.0f; |
|
|
|
na = a*255.0f; |
|
|
|
|
|
|
|
dstp->w = w; |
|
|
|
dstp->h = h; |
|
|
|
pipi_flood_fill_stack_scanline_u32(dstp, px, py, (nr<<16)|(ng<<8)|(nb), dstdata[px+py*w]); |
|
|
|
pipi_flood_fill_stack_scanline_u32(dstp, px, py, (na<<24)|(nr<<16)|(ng<<8)|(nb), dstdata[px+py*w]); |
|
|
|
|
|
|
|
} else { |
|
|
|
int gray = (dst->last_modified == PIPI_PIXELS_Y_F); |
|
|
|
float *dstdata; |
|
|
|
float or, og, ob; |
|
|
|
float or, og, ob, oa; |
|
|
|
|
|
|
|
dstp = gray ? pipi_getpixels(dst, PIPI_PIXELS_Y_F) |
|
|
|
: pipi_getpixels(dst, PIPI_PIXELS_RGBA_F); |
|
|
@@ -107,11 +108,12 @@ int pipi_flood_fill(pipi_image_t *src, |
|
|
|
or = dstdata[(px+py*w)*4]; |
|
|
|
og = dstdata[(px+py*w)*4 + 1]; |
|
|
|
ob = dstdata[(px+py*w)*4 + 2]; |
|
|
|
oa = dstdata[(px+py*w)*4 + 3]; |
|
|
|
|
|
|
|
dstp->w = w; |
|
|
|
dstp->h = h; |
|
|
|
|
|
|
|
pipi_flood_fill_stack_scanline_float(dstp, px, py, r, g, b, or, og, ob); |
|
|
|
pipi_flood_fill_stack_scanline_float(dstp, px, py, r, g, b, a, or, og, ob, oa); |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
@@ -177,8 +179,8 @@ void pipi_flood_fill_stack_scanline_u32(pipi_pixels_t *dstp, |
|
|
|
/* Float version. Much slower, but supports HDR and (soon antialiasing) */ |
|
|
|
static void pipi_flood_fill_stack_scanline_float(pipi_pixels_t *dstp, |
|
|
|
int x, int y, |
|
|
|
float nr, float ng, float nb, |
|
|
|
float or, float og, float ob) |
|
|
|
float nr, float ng, float nb, float na, |
|
|
|
float or, float og, float ob, float oa) |
|
|
|
{ |
|
|
|
if((nr==or) && (ng==og) && (nb==ob)) return; |
|
|
|
|
|
|
@@ -214,6 +216,7 @@ static void pipi_flood_fill_stack_scanline_float(pipi_pixels_t *dstp, |
|
|
|
cur_line[x*4] = nr; |
|
|
|
cur_line[x*4 + 1] = ng; |
|
|
|
cur_line[x*4 + 2] = nb; |
|
|
|
cur_line[x*4 + 3] = na; |
|
|
|
|
|
|
|
if(!left && x > 0 && validate_pixel_f(cur_line[xm1], |
|
|
|
cur_line[xm1 + 1], |
|
|
|