public static Texture2D ImageFromStream(WADImage image)
        {
            Texture2D Image = new Texture2D(GraphicsDevice, (int)image.Width, (int)image.Height);

            Image = Texture2D.FromStream(GraphicsDevice, GetBitmapStream(image));

            return(Image);
        }
        public static Stream GetBitmapStream(WADImage img)
        {
            Bitmap Bmp = GetBitmap(img);


            MemoryStream Stream = new MemoryStream();

            //var Stream = File.OpenWrite("image.bmp");
            Bmp.Save(Stream, System.Drawing.Imaging.ImageFormat.Png);


            return(Stream);
        }
Exemple #3
0
        public static Bitmap GetBitmap(WADImage image)
        {
            Bitmap b = new Bitmap((int)image.Width, (int)image.Height);

            for (int h = 0; h < image.Height; ++h)
            {
                for (int w = 0; w < image.Width; ++w)
                {
                    var pix = image.Pixels[h, w];
                    b.SetPixel(w, h, System.Drawing.Color.FromArgb(pix.Opacity, pix.R, pix.G, pix.B));
                }
            }
            return(b);
        }
        public static Texture2D ImageFromWADArchive(int id, int value)
        {
            Texture2D texture = new Texture2D(GraphicsDevice, 0, 0);


            if (WADImages.Count > 0)
            {
                WAD      wad = WADImages[id];
                WADImage img = wad.Images[value];

                texture = ImageFromStream(img);
            }


            return(texture);
        }