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); }
public int AllocFont() { Font font = null; if (_fontsNumber + 1 > _fonts.Length) { _fonts = new Font[_fonts.Length]; if (_fonts == null) { return(-1); } } font = new Font(); if (font == null) { goto error; } font.Glyphs = (FontGlyph *)CRuntime.malloc((ulong)(sizeof(FontGlyph) * 256)); if (font.Glyphs == null) { goto error; } font.GlyphsCount = 256; font.GlyphsNumber = 0; _fonts[_fontsNumber++] = font; return(_fontsNumber - 1); error: ; FreeFont(font); return(-1); }
public FontAtlas(int w, int h, int count) { Width = w; Height = h; Nodes = (FontAtlasNode *)CRuntime.malloc((ulong)(sizeof(FontAtlasNode) * count)); CRuntime.memset(Nodes, 0, (ulong)(sizeof(FontAtlasNode) * count)); count = 0; NodesCount = count; Nodes[0].X = 0; Nodes[0].Y = 0; Nodes[0].Width = (short)w; NodesNumber++; }
public FontSystem(FontSystemParams p) { _params_ = p; _scratch = (byte *)CRuntime.malloc((ulong)96000); atlas = new FontAtlas(_params_.Width, _params_.Height, 256); _fonts = new Font[4]; _fontsNumber = 0; _itw = 1.0f / _params_.Width; _ith = 1.0f / _params_.Height; _texData = new byte[_params_.Width * _params_.Height]; Array.Clear(_texData, 0, _texData.Length); _dirtyRect[0] = _params_.Width; _dirtyRect[1] = _params_.Height; _dirtyRect[2] = 0; _dirtyRect[3] = 0; AddWhiteRect(2, 2); PushState(); ClearState(); }
private static void *stbi__malloc(int size) { return(CRuntime.malloc((ulong)size)); }