]> git.tdb.fi Git - libs/gui.git/commitdiff
Add pixel formats with a padding component
authorMikko Rasa <tdb@tdb.fi>
Thu, 10 Oct 2013 17:55:47 +0000 (20:55 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 10 Oct 2013 17:55:47 +0000 (20:55 +0300)
source/graphics/pixelformat.h
source/graphics/png/pngloader.cpp
source/graphics/quartz/quartzloader.cpp

index 891ba7c34efdbe7544d2138f05926a0336f25a10..abb800cff94e07be4994f54245ecba4bfe7bac3c 100644 (file)
@@ -11,8 +11,10 @@ enum PixelFormat
        LUMINANCE_ALPHA,
        RGB,
        RGBA,
+       RGBX,
        BGR,
-       BGRA
+       BGRA,
+       BGRX
 };
 
 } // namespace Graphics
index 50d58b3e3d9fabef282e1f2bf6574ba228f00998..35e6a971de3981bbd7b3deb501b5359bea3199fb 100644 (file)
@@ -80,14 +80,11 @@ void PngLoader::load(Image::Data &data)
        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);
index a7c610d4ab62094fa88c8969ea8bdb5fe6e76cdf..aa11daaedff1fe6def85092da71a16501f55b272 100644 (file)
@@ -102,7 +102,9 @@ void QuartzLoader::load(Image::Data &data)
                {
                        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");
@@ -118,7 +120,7 @@ void QuartzLoader::load(Image::Data &data)
 
                CFRelease(image);
 
-               if(alpha==kCGImageAlphaNoneSkipFirst || alpha==kCGImageAlphaNoneSkipLast)
+               if(alpha==kCGImageAlphaNoneSkipFirst)
                {
                        const char *src = data.data;
                        if(alpha==kCGImageAlphaNoneSkipFirst)