From 6009e72fc64f2c0da16494a08a05f39e9d0a2873 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 28 Aug 2004 08:29:13 +0000 Subject: [PATCH] simplify a little, comment --- stepmania/src/RageBitmapTexture.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index a5f329d1d2..8fdee6a426 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -211,21 +211,23 @@ void RageBitmapTexture::Create() default: RageException::Throw( "Invalid color depth: %d bits", actualID.iColorDepth ); } + } - /* It's either not a paletted image, or we can't handle paletted textures. - * Convert to the desired RGBA format, dithering if appropriate. */ - if( actualID.bDither && - (pixfmt==RageDisplay::FMT_RGBA4 || pixfmt==RageDisplay::FMT_RGB5A1) ) /* Don't dither if format is 32bpp; there's no point. */ - { - /* Dither down to the destination format. */ - const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); - RageSurface *dst = CreateSurface( img->w, img->h, pfd->bpp, - pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] ); + /* Dither if appropriate. XXX: This is a special case: don't bother dithering to + * RGBA8888. We actually want to dither only if the destination has greater color + * depth on at least one color channel than the source. For example, it doesn't + * make sense to do this when pixfmt is RGBA5551 if the image is only RGBA555. */ + if( actualID.bDither && + (pixfmt==RageDisplay::FMT_RGBA4 || pixfmt==RageDisplay::FMT_RGB5A1) ) + { + /* Dither down to the destination format. */ + const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); + RageSurface *dst = CreateSurface( img->w, img->h, pfd->bpp, + pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] ); - SM_SDL_ErrorDiffusionDither(img, dst); - delete img; - img = dst; - } + SM_SDL_ErrorDiffusionDither(img, dst); + delete img; + img = dst; } /* This needs to be done *after* the final resize, since that resize