public static STB.Image DefaultPreload(string name, Stream stream, TextureLoadOptions options) { var image = new STB.Image( stream, false, options.Premultiply, options.FloatingPoint, options.Enable16Bit, options.GenerateMips, options.sRGBFromLinear || options.sRGB, options.EnableGrayscale ); if (options.sRGBFromLinear || options.sRGBToLinear) { ApplyColorSpaceConversion(image, options); } return(image); }
private unsafe static void ApplyColorSpaceConversion(STB.Image img, TextureLoadOptions options) { if (img.IsFloatingPoint || img.Is16Bit) { throw new NotImplementedException(); } var pData = (byte *)img.Data; var pEnd = pData + img.DataLength; var table = options.sRGBFromLinear ? ColorSpace.LinearByteTosRGBByteTable : ColorSpace.sRGBByteToLinearByteTable; for (; pData < pEnd; pData++) { *pData = table[*pData]; } }