this should fix the smudge boundries

This commit is contained in:
Albert Cahalan 2004-12-07 01:42:07 +00:00
parent df3c31531d
commit 6836e565b4
2 changed files with 50 additions and 60 deletions

View file

@ -8,7 +8,7 @@ http://www.newbreedsoftware.com/tuxpaint/
2004.December.5 (0.9.15)
* New clipped_getpixel function. It works on 3 sides so far. :-(
* getpixel function now considers edges as extending to infinity
Albert Cahalan <albert@users.sf.net>
* New smudge tool!

View file

@ -767,7 +767,6 @@ static SDL_Surface * thumbnail(SDL_Surface * src, int max_x, int max_y,
static Uint32 getpixel(SDL_Surface * surface, int x, int y);
static void putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel);
static Uint32 clipped_getpixel(SDL_Surface * surface, int x, int y);
static void clipped_putpixel(SDL_Surface * dest, int x, int y, Uint32 c);
static void debug(const char * const str);
@ -4181,13 +4180,13 @@ static void blit_magic(int x, int y, int button_down)
continue;
// it is on the circle, so grab it
SDL_GetRGB(clipped_getpixel(canvas, x+ix-16, y+iy-16), last->format, &r, &g, &b);
SDL_GetRGB(getpixel(canvas, x+ix-16, y+iy-16), last->format, &r, &g, &b);
state[ix][iy][0] = rate*state[ix][iy][0] + (1.0-rate)*sRGB_to_linear_table[r];
state[ix][iy][1] = rate*state[ix][iy][1] + (1.0-rate)*sRGB_to_linear_table[g];
state[ix][iy][2] = rate*state[ix][iy][2] + (1.0-rate)*sRGB_to_linear_table[b];
// opacity 100% --> new data not blended w/ existing data
clipped_putpixel(canvas, x+ix-16, y+iy-16, SDL_MapRGB(canvas->format, linear_to_sRGB(state[ix][iy][0]), linear_to_sRGB(state[ix][iy][1]), linear_to_sRGB(state[ix][iy][2])));
putpixel(canvas, x+ix-16, y+iy-16, SDL_MapRGB(canvas->format, linear_to_sRGB(state[ix][iy][0]), linear_to_sRGB(state[ix][iy][1]), linear_to_sRGB(state[ix][iy][2])));
}
SDL_UnlockSurface(canvas);
}
@ -7876,10 +7875,16 @@ static Uint32 getpixel(SDL_Surface * surface, int x, int y)
pixel = 0;
/* Assuming the X/Y values are within the bounds of this surface... */
/* get the X/Y values within the bounds of this surface */
if (x < 0)
x = 0;
if (x > surface->w - 1)
x = surface->w - 1;
if (y > surface->h - 1)
y = surface->h - 1;
if (y < 0)
y = 0;
if (x >= 0 && y >= 0 && x < surface -> w && y < surface -> h)
{
/* SDL_LockSurface(surface); */
@ -7917,26 +7922,11 @@ static Uint32 getpixel(SDL_Surface * surface, int x, int y)
pixel = *(Uint32 *)p;
/* SDL_UnlockSurface(surface); */
}
return pixel;
}
static Uint32 clipped_getpixel(SDL_Surface * src, int x, int y)
{
if (x < 96)
x = 96;
if (x >= WINDOW_WIDTH - 96)
x = WINDOW_WIDTH - 96 - 1;
if (y < 0)
y = 0;
if (y >= 48 * 7 + 40 + HEIGHTOFFSET)
y = 48 * 7 + 40 + HEIGHTOFFSET - 1;
return getpixel(src, x, y);
}
/* Draw a single pixel into the surface: */
static void putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel)