Esempio n. 1
0
        public static int stbi_write_hdr_core(stbi__write_context s, int x, int y, int comp, float *data)
        {
            if ((y <= 0) || (x <= 0) || (data == null))
            {
                return(0);
            }

            var scratch = (byte *)(CRuntime.malloc((ulong)(x * 4)));

            int i;
            var header = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
            var bytes  = Encoding.UTF8.GetBytes(header);

            fixed(byte *ptr = bytes)
            {
                s.func(s.context, ((sbyte *)ptr), bytes.Length);
            }

            var str = string.Format("EXPOSURE=          1.0000000000000\n\n-Y {0} +X {1}\n", y, x);

            bytes = Encoding.UTF8.GetBytes(str);
            fixed(byte *ptr = bytes)
            {
                s.func(s.context, ((sbyte *)ptr), bytes.Length);
            }

            for (i = 0; i < y; i++)
            {
                stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp * i * x);
            }
            CRuntime.free(scratch);
            return(1);
        }
Esempio n. 2
0
 private static void *stbi__malloc(int size)
 {
     return(CRuntime.malloc((ulong)size));
 }