nanogui: GrDrawImageToFit fail with PNG image with alpha layer
Subject:
GrDrawImageToFit fail with PNG image with alpha layer
From:
Daniel ####@####.####
Date:
3 Jun 2010 13:01:27 -0000
Message-Id: <AANLkTikaqKuCKqrPrVpTHC0_7GBl0Kg8h1z-PWkD3YGt@mail.gmail.com>
This:
> GrDrawImageToFit(GrNewPixmap(640, 480, NULL),
> myGC, 0, 0, 640, 480,
> GrLoadImageFromFile("/path/to/png_with_alpha_channel.png", 0));
fails with the following error:
> nano-X: /path/to/microwin/src/drivers/fblin24.c: 35: linear24_drawpixel: Assertion `c < psd->ncolors' failed.
The function is defined like this:
> /* Set pixel at x, y, to pixelval c*/
> static void linear24_drawpixel(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c)
and the assertion looks like:
> assert (c < psd->ncolors);
It seems like the PNG buffer is read as 32 bit values, but the
function quickly thereafter turn the pixelval into r, g and b:
> r = PIXEL888RED(c);
> g = PIXEL888GREEN(c);
> b = PIXEL888BLUE(c);
And the pure 'c' is never used again. How about just remove that
assertion? What would then fail? What would else be a way to get
fblin24 handle png's with alpha chan?
Best Regards
Daniel