Exemplo n.º 1
0
        public override ITexture FromArray(byte[] data, Size size, ColorBits bits)
        {
            var ms = new MemoryStream(data);

            data = new byte[size.Width * size.Height * 4];
            for (var i = 0; i < data.Length; i += 4)
            {
                Colors.ReadColorRgba(ms, (int)bits, data, i);
            }
            ms.Close();

            var img = new Godot.Image();

            img.CreateFromData(size.Width, size.Height, false, Godot.Image.Format.Rgba8, data);
            GodotTexture tex = new GodotTexture(img, size);

            return(tex);
        }
Exemplo n.º 2
0
        // data form argb 8 bit
        public override ITexture FromArray(byte[] data, Size size)
        {
            var img = new Godot.Image();

            img.Create(size.Width, size.Height, false, Godot.Image.Format.Rgba8);
            img.Lock();
            for (int i = 0; i < size.Width; i++)
            {
                for (int j = 0; j < size.Height; j++)
                {
                    var idx   = j * size.Width + i;
                    var color = Godot.Color.Color8(data[idx], data[idx + 1], data[idx + 2], data[idx + 3]);
                    img.SetPixel(i, j, color);
                }
            }
            img.Unlock();

            GodotTexture tex = new GodotTexture(img, size);

            return(tex);
        }