-PixelComponents storage_pixelformat_from_graphics(Graphics::PixelFormat pf)
-{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- switch(pf)
- {
- case Graphics::RGBX:
- case Graphics::BGR:
- case Graphics::BGRX: return RGB;
- case Graphics::BGRA: return RGBA;
- default: return pixelformat_from_graphics(pf);
- }
-#pragma GCC diagnostic pop
-}
-
-PixelFormat pixelformat_from_image(const Graphics::Image &image)
-{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- PixelComponents comp = pixelformat_from_graphics(image.get_format());
-#pragma GCC diagnostic pop
- return make_pixelformat(comp, UNSIGNED_BYTE);
-}
-
-PixelFormat make_pixelformat(PixelComponents comp, DataType type, bool srgb)
-{
- if(srgb && type!=UNSIGNED_BYTE && comp!=RGB && comp!=RGBA && comp!=BGR && comp!=BGRA)
- throw invalid_argument("make_pixelformat");
-
- switch(comp)
- {
- case RED:
- switch(type)
- {
- case UNSIGNED_BYTE: return R8;
- case HALF_FLOAT: return R16F;
- case FLOAT: return R32F;
- default: throw invalid_argument("make_pixelformat");
- }
- case RG:
- switch(type)
- {
- case UNSIGNED_BYTE: return RG8;
- case HALF_FLOAT: return RG16F;
- case FLOAT: return RG32F;
- default: throw invalid_argument("make_pixelformat");
- }
- case RGB:
- switch(type)
- {
- case UNSIGNED_BYTE: return (srgb ? SRGB8 : RGB8);
- case HALF_FLOAT: return RGB16F;
- case FLOAT: return RGB32F;
- default: throw invalid_argument("make_pixelformat");
- }
- case RGBA:
- switch(type)
- {
- case UNSIGNED_BYTE: return (srgb ? SRGB8_ALPHA8 : RGBA8);
- case HALF_FLOAT: return RGBA16F;
- case FLOAT: return RGBA32F;
- default: throw invalid_argument("make_pixelformat");
- }
- case BGR:
- if(type!=UNSIGNED_BYTE)
- throw invalid_argument("make_pixelformat");
- return (srgb ? BGR8 : SBGR8);
- case BGRA:
- if(type!=UNSIGNED_BYTE)
- throw invalid_argument("make_pixelformat");
- return (srgb ? BGRA8 : SBGR8_ALPHA8);
- case LUMINANCE:
- if(type!=UNSIGNED_BYTE)
- throw invalid_argument("make_pixelformat");
- return LUMINANCE8;
- case LUMINANCE_ALPHA:
- if(type!=UNSIGNED_BYTE)
- throw invalid_argument("make_pixelformat");
- return LUMINANCE8;
- case STENCIL_INDEX:
- if(type!=UNSIGNED_BYTE)
- throw invalid_argument("make_pixelformat");
- return STENCIL_INDEX8;
- case DEPTH_COMPONENT:
- switch(type)
- {
- case UNSIGNED_SHORT: return DEPTH_COMPONENT16;
- case UNSIGNED_INT: return DEPTH_COMPONENT32;
- case FLOAT: return DEPTH_COMPONENT32F;
- default: throw invalid_argument("make_pixelformat");
- }
- default:
- throw invalid_argument("make_pixelformat");
- }
-}
-
-PixelFormat get_base_pixelformat(PixelFormat pf)