Clean up resolution fallback logic

Add video settings for G400
Working on composited text
This commit is contained in:
Chris Danford
2003-06-05 19:29:27 +00:00
parent 43819f68c6
commit 428d560a6b
31 changed files with 602 additions and 310 deletions
+63
View File
@@ -602,6 +602,69 @@ void mySDL_WM_SetIcon( CString sIconFile )
SDL_FreeSurface(srf);
}
void mySDL_BlitSurfaceSmartBlend(
SDL_Surface* src, SDL_Rect *srcrect,
SDL_Surface* dst, SDL_Rect *dstrect )
{
/* Can't blit to paletted surfaces. */
ASSERT(dst->format->BytesPerPixel > 1);
/* Rects must be same dimensions. */
ASSERT( srcrect->w==dstrect->w && srcrect->h==dstrect->h );
/* TODO: Add clipping.
* For now, just ASSERT if out of bounds. */
ASSERT(
srcrect->x >= 0 &&
srcrect->x+srcrect->w <= src->w &&
srcrect->y >= 0 &&
srcrect->y+srcrect->h <= src->h );
ASSERT(
dstrect->x >= 0 &&
dstrect->x+dstrect->w <= dst->w &&
dstrect->y >= 0 &&
dstrect->y+dstrect->h <= dst->h );
/* For each row: */
for(int row = 0; row < srcrect->h; ++row)
{
const Uint8 *srcp = (const Uint8 *)src->pixels;
srcp += (srcrect->y+row) * src->pitch;
srcp += srcrect->x * src->format->BytesPerPixel;
Uint8 *dstp = (Uint8 *)dst->pixels;
dstp += (dstrect->y+row) * dst->pitch;
dstp += dstrect->x * dst->format->BytesPerPixel;
/* For each pixel in row: */
for(int col = 0; col < srcrect->w; ++col)
{
Uint8 srcColors[4];
mySDL_GetRGBAV(srcp, src, srcColors);
Uint8 dstColors[4];
mySDL_GetRGBAV(dstp, dst, dstColors);
float fColorWeightSrc = srcColors[3] / (float)(srcColors[3]+dstColors[3]);
float fColorWeightDst = dstColors[3] / (float)(srcColors[3]+dstColors[3]);
Uint32 temp[4];
temp[0] = srcColors[0] * fColorWeightSrc + dstColors[0] * fColorWeightDst;
temp[1] = srcColors[1] * fColorWeightSrc + dstColors[1] * fColorWeightDst;
temp[2] = srcColors[2] * fColorWeightSrc + dstColors[2] * fColorWeightDst;
temp[3] = srcColors[3] + (dstColors[3] * (255-srcColors[3]))/255;
Uint8 blendedColors[4] = { temp[0], temp[1], temp[2], temp[3] };
mySDL_SetRGBAV(dstp, dst, blendedColors);
/* Next column */
srcp += src->format->BytesPerPixel;
dstp += dst->format->BytesPerPixel;
}
}
}
struct SurfaceHeader
{
int width, height, pitch;