1 #include <msp/strings/format.h>
2 #include "pixelformat.h"
9 void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
11 if(conv.get()=="COLOR_INDEX")
13 else if(conv.get()=="STENCIL_INDEX")
15 else if(conv.get()=="DEPTH_COMPONENT")
16 fmt = DEPTH_COMPONENT;
17 else if(conv.get()=="RED")
19 else if(conv.get()=="GREEN")
21 else if(conv.get()=="BLUE")
23 else if(conv.get()=="ALPHA")
25 else if(conv.get()=="RGB")
27 else if(conv.get()=="RGBA")
29 else if(conv.get()=="BGR")
31 else if(conv.get()=="BGRA")
33 else if(conv.get()=="LUMINANCE")
35 else if(conv.get()=="LUMINANCE_ALPHA")
36 fmt = LUMINANCE_ALPHA;
38 throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
41 PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
45 case Graphics::COLOR_INDEX: return COLOR_INDEX;
46 case Graphics::LUMINANCE: return LUMINANCE;
47 case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA;
48 case Graphics::RGB: return RGB;
49 case Graphics::RGBA: return RGBA;
50 case Graphics::BGR: return BGR;
51 case Graphics::BGRA: return BGRA;
52 default: throw invalid_argument("pixelformat_from_graphics");
56 PixelFormat get_base_pixelformat(PixelFormat pf)
62 case RGB32F: return RGB;
65 case RGBA32F: return RGBA;
68 case LUMINANCE32F: return LUMINANCE;
69 case LUMINANCE_ALPHA8:
70 case LUMINANCE_ALPHA16F:
71 case LUMINANCE_ALPHA32F: return LUMINANCE_ALPHA;