rds1983 / StbSharp

C# port of the famous C framework
69 stars 8 forks source link

Opentk compat #1

Open ghost opened 7 years ago

ghost commented 7 years ago

Hey, Im currently working with OpenTK and trying to use StbSharp to load a texture(in dot net core 2) i have tried using

        private byte[] LoadTexture(string filename, out int width, out int height)
        {
            ImageReader loader = new ImageReader();
            using (Stream stream = File.Open(filename, FileMode.Open)) 
            {
                byte[] buffer = File.ReadAllBytes(filename);
                Image image = Stb.LoadFromMemory(buffer, Stb.STBI_rgb_alpha);

                width = image.Width;
                height = image.Height;
                return image.Data;
            }
        }

and using the returning bytes directly with opentk which doesnt seem Does anyone have any advice?

ghost commented 7 years ago

i have also tried

        private byte[] LoadTexture(string filename, out int width, out int height)
        {
            ImageReader loader = new ImageReader();
            using (Stream stream = File.Open(filename, FileMode.Open))
            {
                Image img = loader.Read(stream, Stb.STBI_rgb_alpha);

                width = img.Width;
                height = img.Height;
                Console.WriteLine("width: " + width + " height: " + height);
                return img.Data;
            }
        }