Beispiel #1
0
        public static ImageSequence LoadFromTgas(String pathName)
        {
            // First we load up the Data In the Serialization file.
            String        gameDataObjectXMLPath = Path.Combine(pathName, "ImageSequence");
            ImageSequence sequenceLoaded        = new ImageSequence();

            // Now lets look for and load up any images that we find.
            String[]      tgaFilesArray  = Directory.GetFiles(pathName, "*.tga");
            List <String> sortedTgaFiles = new List <string>(tgaFilesArray);

            // Make sure they are sorted.
            sortedTgaFiles.Sort();
            sequenceLoaded.imageList = new List <ImageBuffer>();
            int imageIndex = 0;

            foreach (String tgaFile in sortedTgaFiles)
            {
                sequenceLoaded.AddImage(new ImageBuffer(new BlenderPreMultBGRA()));
                Stream imageStream = File.Open(tgaFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                ImageTgaIO.LoadImageData(sequenceLoaded.imageList[imageIndex], imageStream, 32);
                imageIndex++;
            }

            return(sequenceLoaded);
        }
Beispiel #2
0
        private static bool ConvertImageToImageBuffer(ImageBuffer destImage, SixLabors.ImageSharp.Image imageIn)
        {
            var tgaSave = new MemoryStream();
            var encoder = new SixLabors.ImageSharp.Formats.Tga.TgaEncoder();

            encoder.BitsPerPixel = SixLabors.ImageSharp.Formats.Tga.TgaBitsPerPixel.Pixel32;
            encoder.Compression  = SixLabors.ImageSharp.Formats.Tga.TgaCompression.None;
            imageIn.SaveAsTga(tgaSave, encoder);
            tgaSave.Seek(0, SeekOrigin.Begin);
            if (ImageTgaIO.LoadImageData(destImage, tgaSave, 32))
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        public static ImageSequence LoadFromTgas(string pathName)
        {
            var sequenceLoaded = new ImageSequence();

            // Now lets look for and load up any images that we find.
            var sortedTgaFiles = Directory.GetFiles(pathName, "*.tga").OrderBy(s => s);

            foreach (string tgaFile in sortedTgaFiles)
            {
                using (var imageStream = File.OpenRead(tgaFile))
                {
                    var imageBuffer = new ImageBuffer(new BlenderPreMultBGRA());
                    ImageTgaIO.LoadImageData(imageBuffer, imageStream, 32);
                    sequenceLoaded.AddImage(imageBuffer);
                }
            }

            return(sequenceLoaded);
        }