}
}
+PixelComponents swizzle_components(PixelComponents comp, ComponentSwizzle swiz)
+{
+ if(swiz==NO_SWIZZLE)
+ return comp;
+ else if(comp==RED && swiz==R_TO_LUMINANCE)
+ return LUMINANCE;
+ else if(comp==RG && swiz==RG_TO_LUMINANCE_ALPHA)
+ return LUMINANCE_ALPHA;
+ else if(comp==RGB && swiz==RGB_TO_BGR)
+ return BGR;
+ else if(comp==RGBA && swiz==RGB_TO_BGR)
+ return BGRA;
+ else if(comp==RGBA && swiz==RGBA_TO_RGB)
+ return RGB;
+ else if(comp==BGRA && swiz==RGBA_TO_RGB)
+ return BGR;
+ else
+ throw invalid_argument("swizzle_components");
+}
+
+PixelComponents unswizzle_components(PixelComponents comp, ComponentSwizzle swiz)
+{
+ if(swiz==NO_SWIZZLE)
+ return comp;
+ else if(comp==LUMINANCE && swiz==R_TO_LUMINANCE)
+ return RED;
+ else if(comp==LUMINANCE_ALPHA && swiz==RG_TO_LUMINANCE_ALPHA)
+ return RG;
+ else if(comp==BGR && swiz==RGB_TO_BGR)
+ return RGB;
+ else if(comp==BGRA && swiz==RGB_TO_BGR)
+ return RGBA;
+ else if(comp==RGB && swiz==RGBA_TO_RGB)
+ return RGBA;
+ else if(comp==BGR && swiz==RGBA_TO_RGB)
+ return BGRA;
+ else
+ throw invalid_argument("swizzle_components");
+}
+
PixelFormat pixelformat_from_image(const Graphics::Image &image, bool srgb)
{
PixelComponents comp = components_from_graphics(image.get_format());