]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/pixelformat.cpp
Store implementation limits in a central struct
[libs/gl.git] / source / core / pixelformat.cpp
index 87191c3423122aefde6b7e38110daae5d28cb4d0..9a28cdcebfee50d3de079bc96d3c96baa0892212 100644 (file)
@@ -31,7 +31,7 @@ void operator>>(const LexicalConverter &conv, PixelComponents &comp)
        else if(conv.get()=="LUMINANCE_ALPHA")
                comp = LUMINANCE_ALPHA;
        else
-               throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
+               throw lexical_error(format("conversion of '%s' to PixelComponents", conv.get()));
 }
 
 void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
@@ -82,9 +82,16 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
                fmt = DEPTH_COMPONENT32F;
        else
        {
-               PixelComponents comp;
-               conv >> comp;
-               fmt = make_pixelformat(comp, (comp==DEPTH_COMPONENT ? FLOAT : UNSIGNED_BYTE));
+               if(conv.get()=="SRGB")
+                       fmt = SRGB8;
+               else if(conv.get()=="SRGB_ALPHA")
+                       fmt = SRGB8_ALPHA8;
+               else
+               {
+                       PixelComponents comp;
+                       conv >> comp;
+                       fmt = make_pixelformat(comp, (comp==DEPTH_COMPONENT ? FLOAT : UNSIGNED_BYTE));
+               }
                IO::print(IO::cerr, "Warning: deprecated conversion of '%s' to PixelFormat\n", conv.get());
        }
 }
@@ -329,6 +336,11 @@ DataType get_component_type(PixelFormat pf)
        }
 }
 
+bool is_srgb(PixelFormat pf)
+{
+       return (pf==SRGB8 || pf==SRGB8_ALPHA8 || pf==SBGR8 || pf==SBGR8_ALPHA8);
+}
+
 unsigned get_pixel_size(PixelFormat pf)
 {
        return get_component_count(pf)*get_type_size(get_component_type(pf));