Properly handles a variety of PNG formats when loading Starter images
and turning them into thumbnails. (Tested with indexed PNGs, and PNGs where RGB colors were stored, even where pixels were fully transparent.)
This commit is contained in:
parent
c8b96d5364
commit
680a8c314f
2 changed files with 37 additions and 9 deletions
|
|
@ -9,7 +9,7 @@ http://www.newbreedsoftware.com/tuxpaint/
|
|||
$Id$
|
||||
|
||||
|
||||
2006.January.22 (0.9.16)
|
||||
2006.January.29 (0.9.16)
|
||||
* Interface improvements:
|
||||
-----------------------
|
||||
* Modified "Text" tool so that it correctly handles the 16-bit unicode
|
||||
|
|
@ -45,6 +45,11 @@ $Id$
|
|||
* Added GetSystemFontDir() and amended WIN32 code so that the system fonts
|
||||
option work correctly on Windows.
|
||||
|
||||
* Properly handles a variety of PNG formats when loading Starter images
|
||||
and turning them into thumbnails. (Tested with indexed PNGs, and
|
||||
PNGs where RGB colors were stored, even where pixels were
|
||||
fully transparent.)
|
||||
|
||||
|
||||
2005.November.26 (0.9.15b)
|
||||
|
||||
|
|
|
|||
|
|
@ -1557,6 +1557,8 @@ static SDL_Surface * img_tools[NUM_TOOLS], * img_tool_names[NUM_TOOLS];
|
|||
|
||||
static SDL_Surface * thumbnail(SDL_Surface * src, int max_x, int max_y,
|
||||
int keep_aspect);
|
||||
static SDL_Surface * thumbnail2(SDL_Surface * src, int max_x, int max_y,
|
||||
int keep_aspect, int keep_alpha);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// font stuff
|
||||
|
|
@ -10285,6 +10287,12 @@ static void draw_none(void)
|
|||
|
||||
static SDL_Surface * thumbnail(SDL_Surface * src, int max_x, int max_y,
|
||||
int keep_aspect)
|
||||
{
|
||||
return(thumbnail2(src, max_x, max_y, keep_aspect, 1));
|
||||
}
|
||||
|
||||
static SDL_Surface * thumbnail2(SDL_Surface * src, int max_x, int max_y,
|
||||
int keep_aspect, int keep_alpha)
|
||||
{
|
||||
int x, y;
|
||||
float src_x, src_y, off_x, off_y;
|
||||
|
|
@ -10398,11 +10406,26 @@ static SDL_Surface * thumbnail(SDL_Surface * src, int max_x, int max_y,
|
|||
tg = tg / tmp;
|
||||
ta = ta / tmp;
|
||||
|
||||
putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format,
|
||||
(Uint8) tr,
|
||||
(Uint8) tg,
|
||||
(Uint8) tb,
|
||||
(Uint8) ta));
|
||||
if (keep_alpha == 0 && s->format->Amask != 0)
|
||||
{
|
||||
tr = ((ta * tr) / 255) + (255 - ta);
|
||||
tg = ((ta * tg) / 255) + (255 - ta);
|
||||
tb = ((ta * tb) / 255) + (255 - ta);
|
||||
|
||||
putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format,
|
||||
(Uint8) tr,
|
||||
(Uint8) tg,
|
||||
(Uint8) tb,
|
||||
0xff));
|
||||
}
|
||||
else
|
||||
{
|
||||
putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format,
|
||||
(Uint8) tr,
|
||||
(Uint8) tg,
|
||||
(Uint8) tb,
|
||||
(Uint8) ta));
|
||||
}
|
||||
}
|
||||
#else
|
||||
src_x = x * xscale;
|
||||
|
|
@ -14031,9 +14054,9 @@ void do_open(void)
|
|||
else
|
||||
{
|
||||
/* Turn it into a thumbnail: */
|
||||
|
||||
img1 = SDL_DisplayFormat(img);
|
||||
img2 = thumbnail(img1, THUMB_W - 20, THUMB_H - 20, 0);
|
||||
|
||||
img1 = SDL_DisplayFormatAlpha(img);
|
||||
img2 = thumbnail2(img1, THUMB_W - 20, THUMB_H - 20, 0, 0);
|
||||
SDL_FreeSurface(img1);
|
||||
|
||||
show_progress_bar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue