whitespace cleanup only

This commit is contained in:
Glenn Maynard
2004-03-19 21:56:45 +00:00
parent b44cd86843
commit 3e8664fd61
+16 -11
View File
@@ -23,7 +23,6 @@ static const int DitherMat[DitherMatDim][DitherMatDim] =
}; };
static int DitherMatCalc[DitherMatDim][DitherMatDim]; static int DitherMatCalc[DitherMatDim][DitherMatDim];
static bool DitherMatCalc_initted = false;
/* conv is the ratio from the input to the output. */ /* conv is the ratio from the input to the output. */
static Uint8 DitherPixel(int x, int y, int intensity, int conv) static Uint8 DitherPixel(int x, int y, int intensity, int conv)
@@ -54,9 +53,13 @@ static Uint8 DitherPixel(int x, int y, int intensity, int conv)
void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
{ {
if(!DitherMatCalc_initted) { static bool DitherMatCalc_initted = false;
for(int i = 0; i < DitherMatDim; ++i) { if( !DitherMatCalc_initted )
for(int j = 0; j < DitherMatDim; ++j) { {
for( int i = 0; i < DitherMatDim; ++i )
{
for( int j = 0; j < DitherMatDim; ++j )
{
/* Each value is 0..15. They represent 0/16 through 15/16. /* Each value is 0..15. They represent 0/16 through 15/16.
* Set DitherMatCalc to that value * 65536, so we can do it * Set DitherMatCalc to that value * 65536, so we can do it
* with integer calcs. */ * with integer calcs. */
@@ -67,7 +70,6 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
DitherMatCalc_initted = true; DitherMatCalc_initted = true;
} }
/* We can't dither to paletted surfaces. */ /* We can't dither to paletted surfaces. */
ASSERT( dst->format->BytesPerPixel > 1 ); ASSERT( dst->format->BytesPerPixel > 1 );
@@ -92,17 +94,20 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
const Uint8 alpha_max = Uint8((1 << dst_cbits[3]) - 1); const Uint8 alpha_max = Uint8((1 << dst_cbits[3]) - 1);
/* For each row: */ /* For each row: */
for(int row = 0; row < src->h; ++row) { for( int row = 0; row < src->h; ++row )
{
const Uint8 *srcp = (const Uint8 *) src->pixels + row * src->pitch; const Uint8 *srcp = (const Uint8 *) src->pixels + row * src->pitch;
Uint8 *dstp = (Uint8 *) dst->pixels + row * dst->pitch; Uint8 *dstp = (Uint8 *) dst->pixels + row * dst->pitch;
/* For each pixel: */ /* For each pixel: */
for(int col = 0; col < src->w; ++col) { for( int col = 0; col < src->w; ++col )
{
Uint8 colors[4]; Uint8 colors[4];
mySDL_GetRawRGBAV( srcp, src, colors ); mySDL_GetRawRGBAV( srcp, src, colors );
/* Note that we don't dither the alpha channel. */ /* Note that we don't dither the alpha channel. */
for(int c = 0; c < 3; ++c) { for( int c = 0; c < 3; ++c )
{
/* If the destination has less bits, dither: */ /* If the destination has less bits, dither: */
colors[c] = DitherPixel( col, row, colors[c], conv[c] ); colors[c] = DitherPixel( col, row, colors[c], conv[c] );
} }
@@ -110,7 +115,8 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
/* If the source has no alpha, the conversion formula will end up /* If the source has no alpha, the conversion formula will end up
* with 0; that's fine for color channels, but for alpha we need to * with 0; that's fine for color channels, but for alpha we need to
* be opaque. */ * be opaque. */
if(src_cbits[3] == 0) { if( src_cbits[3] == 0 )
{
colors[3] = alpha_max; colors[3] = alpha_max;
} else { } else {
/* Same as DitherPixel, except it doesn't actually dither; dithering /* Same as DitherPixel, except it doesn't actually dither; dithering
@@ -168,10 +174,9 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst)
// make sure we didn't overflow // make sure we didn't overflow
ASSERT( (Uint8)(originalColors[c] + errorToAdd) == (Sint32)(originalColors[c] + errorToAdd) ); ASSERT( (Uint8)(originalColors[c] + errorToAdd) == (Sint32)(originalColors[c] + errorToAdd) );
} }
mySDL_SetRGBAV(dstp, dst, colorsPlusError);
mySDL_SetRGBAV( dstp, dst, colorsPlusError );
Uint8 ditheredColors[4]; Uint8 ditheredColors[4];
mySDL_GetRGBAV( dstp, dst, ditheredColors ); mySDL_GetRGBAV( dstp, dst, ditheredColors );