Пример #1
0
        public static STLCollection LoadPngs(string[] files, NCER ncer, bool tiled = false)
        {
            var stlFiles = (
                from filePath in files
                let fileName = Path.GetFileNameWithoutExtension(filePath)
                               where int.TryParse(fileName, out var _)
                               let num = int.Parse(fileName)
                                         select(filePath, num))
                           .ToArray();

            int maxNum = stlFiles.Max(i => i.num);
            var stls   = new STL[maxNum + 1];

            Parallel.For(0, stlFiles.Length, i =>
            {
                var(file, num) = stlFiles[i];
                if (new FileInfo(file).Length == 0)
                {
                    stls[num] = null;
                }
                else
                {
                    stls[num] = STL.LoadPng(ncer, file, tiled);
                }
            });
            return(new STLCollection {
                Items = stls.ToList()
            });
        }
Пример #2
0
        public static STLCollection Load(string stlDataFile, string stlInfoFile)
        {
            var stls = new List <STL>();

            using (var dataBr = new BinaryReader(File.OpenRead(stlDataFile)))
            {
                using (var infoBr = new BinaryReader(File.OpenRead(stlInfoFile)))
                {
                    int numItems = infoBr.ReadInt32();
                    int _        = infoBr.ReadInt32(); // max file length
                    for (int i = 0; i < numItems; i++)
                    {
                        var offset = infoBr.ReadUInt32();
                        var len    = infoBr.ReadInt32();
                        if (len == 0)
                        {
                            stls.Add(null);
                        }
                        else
                        {
                            dataBr.BaseStream.Position = offset;
                            stls.Add(STL.Load(dataBr));
                        }
                    }

                    return(new STLCollection {
                        Items = stls
                    });
                }
            }
        }
Пример #3
0
        public static STL Load(BinaryReader br)
        {
            var header = new Header(br);
            var stl    = new STL
            {
                Width   = header.Width,
                Height  = header.Height,
                Palette = RawPalette.Decompress(br.ReadBytes(PaletteDataLength)),
                Pixels  = br.ReadBytes(header.Width * header.Height)
            };

            br.Skip(PaddingLength);
            return(stl);
        }