save alpha, if present

This commit is contained in:
Glenn Maynard
2007-02-24 23:09:56 +00:00
parent d5542f24cf
commit dbd40a9da4
+3 -2
View File
@@ -71,12 +71,13 @@ static void PNG_Warning( png_struct *png, const char *warning )
* objects, and needs to watch out for memleaks. */
static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurface *pImgIn )
{
bool bAlpha = pImgIn->format->Amask != 0;
RageSurface *pImg;
bool bDeleteImg = RageSurfaceUtils::ConvertSurface( pImgIn, pImg, pImgIn->w, pImgIn->h, 32,
Swap32BE( 0xFF000000 ),
Swap32BE( 0x00FF0000 ),
Swap32BE( 0x0000FF00 ),
Swap32BE( 0x00000000 ) );
Swap32BE( 0x000000FF ) );
if( !bDeleteImg )
pImg = pImgIn;
@@ -109,7 +110,7 @@ static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurfac
png_set_write_fn( pPng, &f, RageFile_png_write, RageFile_png_flush );
png_set_compression_level( pPng, 1 );
png_set_IHDR( pPng, pInfo, pImg->w, pImg->h, 8, PNG_COLOR_TYPE_RGB,
png_set_IHDR( pPng, pInfo, pImg->w, pImg->h, 8, bAlpha? PNG_COLOR_TYPE_RGBA:PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );
png_write_info( pPng, pInfo );