save alpha, if present
This commit is contained in:
@@ -71,12 +71,13 @@ static void PNG_Warning( png_struct *png, const char *warning )
|
|||||||
* objects, and needs to watch out for memleaks. */
|
* objects, and needs to watch out for memleaks. */
|
||||||
static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurface *pImgIn )
|
static bool RageSurface_Save_PNG( RageFile &f, char szErrorbuf[1024], RageSurface *pImgIn )
|
||||||
{
|
{
|
||||||
|
bool bAlpha = pImgIn->format->Amask != 0;
|
||||||
RageSurface *pImg;
|
RageSurface *pImg;
|
||||||
bool bDeleteImg = RageSurfaceUtils::ConvertSurface( pImgIn, pImg, pImgIn->w, pImgIn->h, 32,
|
bool bDeleteImg = RageSurfaceUtils::ConvertSurface( pImgIn, pImg, pImgIn->w, pImgIn->h, 32,
|
||||||
Swap32BE( 0xFF000000 ),
|
Swap32BE( 0xFF000000 ),
|
||||||
Swap32BE( 0x00FF0000 ),
|
Swap32BE( 0x00FF0000 ),
|
||||||
Swap32BE( 0x0000FF00 ),
|
Swap32BE( 0x0000FF00 ),
|
||||||
Swap32BE( 0x00000000 ) );
|
Swap32BE( 0x000000FF ) );
|
||||||
if( !bDeleteImg )
|
if( !bDeleteImg )
|
||||||
pImg = pImgIn;
|
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_write_fn( pPng, &f, RageFile_png_write, RageFile_png_flush );
|
||||||
png_set_compression_level( pPng, 1 );
|
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_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );
|
||||||
|
|
||||||
png_write_info( pPng, pInfo );
|
png_write_info( pPng, pInfo );
|
||||||
|
|||||||
Reference in New Issue
Block a user