case PNG_COLOR_TYPE_PALETTE: data.fmt = COLOR_INDEX; break;
case PNG_COLOR_TYPE_GRAY: data.fmt = LUMINANCE; break;
case PNG_COLOR_TYPE_GRAY_ALPHA: data.fmt = LUMINANCE_ALPHA; break;
- case PNG_COLOR_TYPE_RGB: data.fmt = RGB; break;
+ case PNG_COLOR_TYPE_RGB: data.fmt = (nchans==4 ? RGBX : RGB); break;
case PNG_COLOR_TYPE_RGB_ALPHA: data.fmt = RGBA; break;
default: throw unsupported_image_format("unknown color type");
}
- if(nchans==4 && data.fmt==RGB)
- png_set_strip_alpha(priv->png);
-
data.data = new char[data.stride*data.height];
for(unsigned y=0; y<data.height; ++y)
png_read_row(priv->png, reinterpret_cast<png_byte *>(data.data+data.stride*(data.height-1-y)), 0);
{
if(alpha==kCGImageAlphaLast)
data.fmt = RGBA;
- else if(alpha==kCGImageAlphaNone || alpha==kCGImageAlphaNoneSkipFirst || alpha==kCGImageAlphaNoneSkipLast)
+ else if(alpha==kCGImageAlphaNoneSkipLast)
+ data.fmt = RGBX;
+ else if(alpha==kCGImageAlphaNone || alpha==kCGImageAlphaNoneSkipFirst)
data.fmt = RGB;
else
throw unsupported_image_format("unknown alpha mode");
CFRelease(image);
- if(alpha==kCGImageAlphaNoneSkipFirst || alpha==kCGImageAlphaNoneSkipLast)
+ if(alpha==kCGImageAlphaNoneSkipFirst)
{
const char *src = data.data;
if(alpha==kCGImageAlphaNoneSkipFirst)