whitespace cleanup only
This commit is contained in:
@@ -23,7 +23,6 @@ static const int DitherMat[DitherMatDim][DitherMatDim] =
|
||||
};
|
||||
|
||||
static int DitherMatCalc[DitherMatDim][DitherMatDim];
|
||||
static bool DitherMatCalc_initted = false;
|
||||
|
||||
/* conv is the ratio from the input to the output. */
|
||||
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)
|
||||
{
|
||||
if(!DitherMatCalc_initted) {
|
||||
for(int i = 0; i < DitherMatDim; ++i) {
|
||||
for(int j = 0; j < DitherMatDim; ++j) {
|
||||
static bool DitherMatCalc_initted = false;
|
||||
if( !DitherMatCalc_initted )
|
||||
{
|
||||
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.
|
||||
* Set DitherMatCalc to that value * 65536, so we can do it
|
||||
* with integer calcs. */
|
||||
@@ -67,7 +70,6 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
DitherMatCalc_initted = true;
|
||||
}
|
||||
|
||||
|
||||
/* We can't dither to paletted surfaces. */
|
||||
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);
|
||||
|
||||
/* 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;
|
||||
Uint8 *dstp = (Uint8 *) dst->pixels + row * dst->pitch;
|
||||
|
||||
/* For each pixel: */
|
||||
for(int col = 0; col < src->w; ++col) {
|
||||
for( int col = 0; col < src->w; ++col )
|
||||
{
|
||||
Uint8 colors[4];
|
||||
mySDL_GetRawRGBAV( srcp, src, colors );
|
||||
|
||||
/* 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: */
|
||||
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
|
||||
* with 0; that's fine for color channels, but for alpha we need to
|
||||
* be opaque. */
|
||||
if(src_cbits[3] == 0) {
|
||||
if( src_cbits[3] == 0 )
|
||||
{
|
||||
colors[3] = alpha_max;
|
||||
} else {
|
||||
/* 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
|
||||
ASSERT( (Uint8)(originalColors[c] + errorToAdd) == (Sint32)(originalColors[c] + errorToAdd) );
|
||||
|
||||
}
|
||||
mySDL_SetRGBAV(dstp, dst, colorsPlusError);
|
||||
|
||||
mySDL_SetRGBAV( dstp, dst, colorsPlusError );
|
||||
|
||||
Uint8 ditheredColors[4];
|
||||
mySDL_GetRGBAV( dstp, dst, ditheredColors );
|
||||
|
||||
Reference in New Issue
Block a user