Experimental RGB_FONTS; better handling of Alpha vs. Colorkey; other misc not-so-relevant fixes
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1987 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -63,7 +63,7 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
|
|||||||
if (ani[cel_ct].transparent_color == 0)
|
if (ani[cel_ct].transparent_color == 0)
|
||||||
// make RGB=0,0,0 transparent
|
// make RGB=0,0,0 transparent
|
||||||
SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY,
|
SDL_SetColorKey (img[cel_ct], SDL_SRCCOLORKEY,
|
||||||
SDL_MapRGB (img[cel_ct]->format, 0, 0, 0));
|
SDL_MapRGBA (img[cel_ct]->format, 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
if (ani[cel_ct].transparent_color == -1)
|
if (ani[cel_ct].transparent_color == -1)
|
||||||
{ // enforce -1 to mean 'no transparency'
|
{ // enforce -1 to mean 'no transparency'
|
||||||
@@ -111,6 +111,7 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
int x,y;
|
int x,y;
|
||||||
Uint8 r,g,b,a;
|
Uint8 r,g,b,a;
|
||||||
Uint32 p;
|
Uint32 p;
|
||||||
|
Uint32 clear, opaque;
|
||||||
SDL_Color colors[256];
|
SDL_Color colors[256];
|
||||||
SDL_Surface *new_surf;
|
SDL_Surface *new_surf;
|
||||||
SDL_PixelFormat* srcfmt = surf->format;
|
SDL_PixelFormat* srcfmt = surf->format;
|
||||||
@@ -118,18 +119,27 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
GetPixelFn getpix;
|
GetPixelFn getpix;
|
||||||
PutPixelFn putpix;
|
PutPixelFn putpix;
|
||||||
|
|
||||||
TYPE_SET (FramePtr->TypeIndexAndFlags, WANT_PIXMAP << FTYPE_SHIFT);
|
TYPE_SET (FramePtr->TypeIndexAndFlags, ROM_DRAWABLE);
|
||||||
INDEX_SET (FramePtr->TypeIndexAndFlags, charInd);
|
INDEX_SET (FramePtr->TypeIndexAndFlags, charInd);
|
||||||
// XXX: Is this still relevant?
|
// XXX: Is this still relevant?
|
||||||
|
|
||||||
//#define ALPHA_FONTS
|
//#define ALPHA_FONTS
|
||||||
|
//#define RGB_FONTS
|
||||||
|
|
||||||
SDL_LockSurface (surf);
|
SDL_LockSurface (surf);
|
||||||
|
|
||||||
|
clear = 0;
|
||||||
|
opaque = 1;
|
||||||
|
|
||||||
#if defined(ALPHA_FONTS)
|
#if defined(ALPHA_FONTS)
|
||||||
// convert png font to truecolor + alpha
|
// convert png font to truecolor + alpha
|
||||||
new_surf = TFB_DrawCanvas_New_TrueColor (surf->w, surf->h, TRUE);
|
new_surf = TFB_DrawCanvas_New_TrueColor (surf->w, surf->h, TRUE);
|
||||||
|
|
||||||
|
#elif defined(RGB_FONTS)
|
||||||
|
// convert png font to truecolor w/ colorkey
|
||||||
|
new_surf = TFB_DrawCanvas_New_TrueColor (surf->w, surf->h, FALSE);
|
||||||
|
opaque = SDL_MapRGB (new_surf->format, 255, 255, 255);
|
||||||
|
|
||||||
#else // indexed fonts
|
#else // indexed fonts
|
||||||
// convert 32-bit png font to indexed
|
// convert 32-bit png font to indexed
|
||||||
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, surf->w, surf->h,
|
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, surf->w, surf->h,
|
||||||
@@ -158,16 +168,18 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
putpix (new_surf, x, y, SDL_MapRGBA (dstfmt,
|
putpix (new_surf, x, y, SDL_MapRGBA (dstfmt,
|
||||||
255, 255, 255, a));
|
255, 255, 255, a));
|
||||||
|
|
||||||
#else // indexed fonts
|
#else // indexed/rgb colorkey fonts
|
||||||
|
// normalize font pixel
|
||||||
if (r == 0 && g == 0 && b == 0)
|
if (r == 0 && g == 0 && b == 0)
|
||||||
putpix (new_surf, x, y, 0);
|
putpix (new_surf, x, y, clear);
|
||||||
else
|
else
|
||||||
putpix (new_surf, x, y, 1);
|
putpix (new_surf, x, y, opaque);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(ALPHA_FONTS)
|
#if !defined(ALPHA_FONTS)
|
||||||
|
#if !defined(RGB_FONTS)
|
||||||
colors[0].r = 0;
|
colors[0].r = 0;
|
||||||
colors[0].g = 0;
|
colors[0].g = 0;
|
||||||
colors[0].b = 0;
|
colors[0].b = 0;
|
||||||
@@ -179,8 +191,9 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetColors (new_surf, colors, 0, 256);
|
SDL_SetColors (new_surf, colors, 0, 256);
|
||||||
SDL_SetColorKey (new_surf, SDL_SRCCOLORKEY, 0);
|
#endif /* !RGB_FONTS */
|
||||||
#endif
|
SDL_SetColorKey (new_surf, SDL_SRCCOLORKEY, clear);
|
||||||
|
#endif /* !ALPHA_FONTS */
|
||||||
|
|
||||||
SDL_UnlockSurface (surf);
|
SDL_UnlockSurface (surf);
|
||||||
SDL_FreeSurface (surf);
|
SDL_FreeSurface (surf);
|
||||||
@@ -193,6 +206,8 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
// I brought it into this function from the only calling
|
// I brought it into this function from the only calling
|
||||||
// function, but I don't know why it was there in the first
|
// function, but I don't know why it was there in the first
|
||||||
// place.
|
// place.
|
||||||
|
// XXX: the +1 appears to be for character and line spacing
|
||||||
|
// text_blt just adds the frame width to move to the next char
|
||||||
|
|
||||||
{
|
{
|
||||||
// This tunes the font positioning to be about what it should
|
// This tunes the font positioning to be about what it should
|
||||||
@@ -218,14 +233,15 @@ processFontChar (FRAMEPTR FramePtr, SDL_Surface *surf, int charInd)
|
|||||||
FRAMEPTR stretch_frame (FRAMEPTR FramePtr, int neww, int newh, int destroy)
|
FRAMEPTR stretch_frame (FRAMEPTR FramePtr, int neww, int newh, int destroy)
|
||||||
{
|
{
|
||||||
FRAMEPTR NewFrame;
|
FRAMEPTR NewFrame;
|
||||||
UBYTE type;
|
CREATE_FLAGS flags;
|
||||||
TFB_Image *tfbImg;
|
TFB_Image *tfbImg;
|
||||||
TFB_Canvas src, dst;
|
TFB_Canvas src, dst;
|
||||||
EXTENT ext;
|
EXTENT ext;
|
||||||
type = (UBYTE)TYPE_GET (GetFrameParentDrawable (FramePtr)
|
|
||||||
|
flags = TYPE_GET (GetFrameParentDrawable (FramePtr)
|
||||||
->FlagsAndIndex) >> FTYPE_SHIFT;
|
->FlagsAndIndex) >> FTYPE_SHIFT;
|
||||||
NewFrame = CaptureDrawable (
|
NewFrame = CaptureDrawable (
|
||||||
CreateDrawable (type, (SIZE)neww, (SIZE)newh, 1));
|
CreateDrawable (flags, (SIZE)neww, (SIZE)newh, 1));
|
||||||
tfbImg = FramePtr->image;
|
tfbImg = FramePtr->image;
|
||||||
LockMutex (tfbImg->mutex);
|
LockMutex (tfbImg->mutex);
|
||||||
src = tfbImg->NormalImg;
|
src = tfbImg->NormalImg;
|
||||||
@@ -246,11 +262,6 @@ void process_rgb_bmp (FRAMEPTR FramePtr, Uint32 *rgba, int maxx, int maxy)
|
|||||||
SDL_Surface *img;
|
SDL_Surface *img;
|
||||||
PutPixelFn putpix;
|
PutPixelFn putpix;
|
||||||
|
|
||||||
// TYPE_SET (FramePtr->TypeIndexAndFlags, WANT_PIXMAP << FTYPE_SHIFT);
|
|
||||||
// INDEX_SET (FramePtr->TypeIndexAndFlags, 1);
|
|
||||||
|
|
||||||
|
|
||||||
// convert 32-bit png font to indexed
|
|
||||||
tfbImg = FramePtr->image;
|
tfbImg = FramePtr->image;
|
||||||
LockMutex (tfbImg->mutex);
|
LockMutex (tfbImg->mutex);
|
||||||
img = (SDL_Surface *)tfbImg->NormalImg;
|
img = (SDL_Surface *)tfbImg->NormalImg;
|
||||||
|
|||||||
Reference in New Issue
Block a user