+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 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;
+ }