]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pixelformat.cpp
Rework exceptions
[libs/gl.git] / source / pixelformat.cpp
index 27a814e21e1c30b946c24cf2fad6287dc073a664..8f742d83c38fcd012e0a46068eb96a0a350820aa 100644 (file)
@@ -1,11 +1,4 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "except.h"
+#include <msp/strings/format.h>
 #include "pixelformat.h"
 
 using namespace std;
@@ -61,7 +54,27 @@ PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
        case Graphics::RGBA: return RGBA;
        case Graphics::BGR: return BGR;
        case Graphics::BGRA: return BGRA;
-       default: throw InvalidParameterValue("Unknown Graphics::PixelFormat");
+       default: throw invalid_argument("pixelformat_from_graphics");
+       }
+}
+
+PixelFormat get_base_pixelformat(PixelFormat pf)
+{
+       switch(pf)
+       {
+       case RGB8:
+       case RGB16F:
+       case RGB32F: return RGB;
+       case RGBA8:
+       case RGBA16F:
+       case RGBA32F: return RGBA;
+       case LUMINANCE8:
+       case LUMINANCE16F:
+       case LUMINANCE32F: return LUMINANCE;
+       case LUMINANCE_ALPHA8:
+       case LUMINANCE_ALPHA16F:
+       case LUMINANCE_ALPHA32F: return LUMINANCE_ALPHA;
+       default: return pf;
        }
 }