From: James Le Cuirot Date: Tue, 27 May 2014 21:28:27 +0000 (+0100) Subject: Add luminance alpha support X-Git-Tag: v1.46~2 X-Git-Url: https://repo.or.cz/w/glpng.git/commitdiff_plain/9311daeaa9c33b470677d1a6e2b0c8879254bbb9 Add luminance alpha support Admittedly I have no idea what this is but it was originally added by Bit Blot because it's needed by Aquaria. --- diff --git a/include/GL/glpng.h b/include/GL/glpng.h index 172a757..96e95e9 100644 --- a/include/GL/glpng.h +++ b/include/GL/glpng.h @@ -57,6 +57,7 @@ extern "C" { #define PNG_SIMPLEMIPMAP PNG_SIMPLEMIPMAPS /* Transparency parameters */ +#define PNG_LUMINANCEALPHA -4 #define PNG_CALLBACKT -3 /* Call the callback function to generate alpha */ #define PNG_ALPHA -2 /* Use alpha channel in PNG file, if there is one */ #define PNG_SOLID -1 /* No transparency */ diff --git a/src/glpng.c b/src/glpng.c index e671bd1..e19c35d 100644 --- a/src/glpng.c +++ b/src/glpng.c @@ -503,7 +503,7 @@ static int pngLoadCommon(int mipmap, int trans, pngInfo *pinfo, png_structp png, } else #endif - if (trans == PNG_SOLID || trans == PNG_ALPHA || color == PNG_COLOR_TYPE_RGB_ALPHA || color == PNG_COLOR_TYPE_GRAY_ALPHA) { + if (trans == PNG_SOLID || trans == PNG_ALPHA || trans == PNG_LUMINANCEALPHA || color == PNG_COLOR_TYPE_RGB_ALPHA || color == PNG_COLOR_TYPE_GRAY_ALPHA) { GLenum glformat; GLint glcomponent; @@ -528,6 +528,9 @@ static int pngLoadCommon(int mipmap, int trans, pngInfo *pinfo, png_structp png, goto finish; } + if (trans == PNG_LUMINANCEALPHA) + glformat = GL_LUMINANCE_ALPHA; + if (mipmap == PNG_BUILDMIPMAPS) Build2DMipmaps(glcomponent, width, height, glformat, data, 1); else if (mipmap == PNG_SIMPLEMIPMAPS)