X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpixelformat.cpp;h=7647717a44ad3d047e7bfbc0d386a575f5564701;hb=00d3ccedefb1a5efb3d2d4625a2b68446703fbab;hp=027ae88c7fe1bb7c5e11290ef5133e3c143b8d05;hpb=5a93cc603eef43617a10b76bc9c19a3272ac1d49;p=libs%2Fgl.git diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index 027ae88c..7647717a 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -105,6 +105,22 @@ PixelFormat get_base_pixelformat(PixelFormat pf) } } +PixelFormat get_srgb_pixelformat(PixelFormat pf) +{ + switch(pf) + { + case RGB: return SRGB; + case RGBA: return SRGB_ALPHA; + case RGB8: return SRGB8; + case RGBA8: return SRGB8_ALPHA8; + case LUMINANCE: return SLUMINANCE; + case LUMINANCE8: return SLUMINANCE8; + case LUMINANCE_ALPHA: return SLUMINANCE_ALPHA; + case LUMINANCE_ALPHA8: return SLUMINANCE8_ALPHA8; + default: return pf; + } +} + unsigned get_component_count(PixelFormat pf) { switch(get_base_pixelformat(pf)) @@ -132,6 +148,30 @@ unsigned get_component_count(PixelFormat pf) } } +unsigned get_component_size(PixelFormat pf) +{ + switch(pf) + { + case RGB16F: + case RGBA16F: + case LUMINANCE16F: + case LUMINANCE_ALPHA16F: + return 2; + case RGB32F: + case RGBA32F: + case LUMINANCE32F: + case LUMINANCE_ALPHA32F: + return 4; + default: + return 1; + } +} + +unsigned get_pixel_size(PixelFormat pf) +{ + return get_component_count(pf)*get_component_size(pf); +} + void require_pixelformat(PixelFormat pf) { switch(pf)