X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpixelformat.cpp;h=27a814e21e1c30b946c24cf2fad6287dc073a664;hb=40020924ebc8b2a82b6f6cea3dc04561121cebfd;hp=738b796c5981fa307c2f9e3f15bc4f94fed1b789;hpb=d1800d7ea80290f4913d0203241cef1409656522;p=libs%2Fgl.git diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index 738b796c..27a814e2 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include "except.h" #include "pixelformat.h" using namespace std; @@ -18,36 +19,51 @@ istream &operator>>(istream &in, PixelFormat &fmt) in>>word; if(word=="COLOR_INDEX") - fmt=COLOR_INDEX; + fmt = COLOR_INDEX; else if(word=="STENCIL_INDEX") - fmt=STENCIL_INDEX; + fmt = STENCIL_INDEX; else if(word=="DEPTH_COMPONENT") - fmt=DEPTH_COMPONENT; + fmt = DEPTH_COMPONENT; else if(word=="RED") - fmt=RED; + fmt = RED; else if(word=="GREEN") - fmt=GREEN; + fmt = GREEN; else if(word=="BLUE") - fmt=BLUE; + fmt = BLUE; else if(word=="ALPHA") - fmt=ALPHA; + fmt = ALPHA; else if(word=="RGB") - fmt=RGB; + fmt = RGB; else if(word=="RGBA") - fmt=RGBA; + fmt = RGBA; else if(word=="BGR") - fmt=BGR; + fmt = BGR; else if(word=="BGRA") - fmt=BGRA; + fmt = BGRA; else if(word=="LUMINANCE") - fmt=LUMINANCE; + fmt = LUMINANCE; else if(word=="LUMINANCE_ALPHA") - fmt=LUMINANCE_ALPHA; + fmt = LUMINANCE_ALPHA; else in.setstate(ios_base::failbit); return in; } +PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf) +{ + switch(pf) + { + case Graphics::COLOR_INDEX: return COLOR_INDEX; + case Graphics::LUMINANCE: return LUMINANCE; + case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA; + case Graphics::RGB: return RGB; + case Graphics::RGBA: return RGBA; + case Graphics::BGR: return BGR; + case Graphics::BGRA: return BGRA; + default: throw InvalidParameterValue("Unknown Graphics::PixelFormat"); + } +} + } // namespace GL } // namespace Msp