X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpixelformat.cpp;h=9a28cdcebfee50d3de079bc96d3c96baa0892212;hb=2d3113a7dbbe4be2f1d1e8980c1c4e42175163da;hp=87191c3423122aefde6b7e38110daae5d28cb4d0;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/pixelformat.cpp b/source/core/pixelformat.cpp index 87191c34..9a28cdce 100644 --- a/source/core/pixelformat.cpp +++ b/source/core/pixelformat.cpp @@ -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));