}
}
-PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat pf)
+PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat pf, bool srgb)
{
+ PixelFormat result;
switch(pf)
{
case Graphics::RGBX:
case Graphics::BGR:
- case Graphics::BGRX: return RGB;
- case Graphics::BGRA: return RGBA;
- default: return pixelformat_from_graphics(pf);
+ case Graphics::BGRX: result = RGB; break;
+ case Graphics::BGRA: result = RGBA; break;
+ default: result = pixelformat_from_graphics(pf);
}
+
+ if(srgb)
+ return get_srgb_pixelformat(result);
+ else
+ return result;
}
PixelFormat get_base_pixelformat(PixelFormat pf)
void operator>>(const LexicalConverter &, PixelFormat &);
PixelFormat pixelformat_from_graphics(Graphics::PixelFormat);
-PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat);
+PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat, bool = false);
PixelFormat get_base_pixelformat(PixelFormat);
PixelFormat get_srgb_pixelformat(PixelFormat);
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(width==0)
- {
- PixelFormat f = storage_pixelformat_from_graphics(img.get_format());
- if(srgb)
- f = get_srgb_pixelformat(f);
- storage(f, w, h);
- }
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h);
else if(w!=width || h!=height)
throw incompatible_data("Texture2D::image");
if(w!=h)
throw incompatible_data("TextureCube::image");
- PixelFormat f = storage_pixelformat_from_graphics(img.get_format());
- if(srgb)
- f = get_srgb_pixelformat(f);
- storage(f, w);
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w);
}
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");