public static float *stbi__ldr_to_hdr(byte *data, int x, int y, int comp)
        {
            var    i = 0;
            var    k = 0;
            var    n = 0;
            float *output;

            if (data == null)
            {
                return(null);
            }
            output = (float *)stbi__malloc_mad4(x, y, comp, sizeof(float), 0);
            if (output == null)
            {
                CRuntime.free(data);
                return((float *)(ulong)(stbi__err("outofmem") != 0 ? 0 : 0));
            }

            if ((comp & 1) != 0)
            {
                n = comp;
            }
            else
            {
                n = comp - 1;
            }
            for (i = 0; i < x * y; ++i)
            {
                for (k = 0; k < n; ++k)
                {
                    output[i * comp + k] =
                        (float)(CRuntime.pow(data[i * comp + k] / 255.0f, stbi__l2h_gamma) * stbi__l2h_scale);
                }
            }

            if (n < comp)
            {
                for (i = 0; i < x * y; ++i)
                {
                    output[i * comp + n] = data[i * comp + n] / 255.0f;
                }
            }

            CRuntime.free(data);
            return(output);
        }
        public static byte *stbi__hdr_to_ldr(float *data, int x, int y, int comp)
        {
            var   i = 0;
            var   k = 0;
            var   n = 0;
            byte *output;

            if (data == null)
            {
                return(null);
            }
            output = (byte *)stbi__malloc_mad3(x, y, comp, 0);
            if (output == null)
            {
                CRuntime.free(data);
                return((byte *)(ulong)(stbi__err("outofmem") != 0 ? 0 : 0));
            }

            if ((comp & 1) != 0)
            {
                n = comp;
            }
            else
            {
                n = comp - 1;
            }
            for (i = 0; i < x * y; ++i)
            {
                for (k = 0; k < n; ++k)
                {
                    var z = (float)CRuntime.pow(data[i * comp + k] * stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 +
                            0.5f;
                    if (z < 0)
                    {
                        z = 0;
                    }
                    if (z > 255)
                    {
                        z = 255;
                    }
                    output[i * comp + k] = (byte)(int)z;
                }

                if (k < comp)
                {
                    var z = data[i * comp + k] * 255 + 0.5f;
                    if (z < 0)
                    {
                        z = 0;
                    }
                    if (z > 255)
                    {
                        z = 255;
                    }
                    output[i * comp + k] = (byte)(int)z;
                }
            }

            CRuntime.free(data);
            return(output);
        }