示例#1
0
文件: TEXI.cs 项目: wabberz/Kuriimu
        public TEXI(Stream input, Stream texi)
        {
            using (var br = new BinaryReaderX(input))
            {
                seri = (SERIList) new XmlSerializer(typeof(SERIList)).Deserialize(XmlReader.Create(texi));

                var width       = (Integer)seri.Parameters.Find(x => x.Name == "w");
                var height      = (Integer)seri.Parameters.Find(x => x.Name == "h");
                var mipMapCount = (Integer)seri.Parameters.Find(x => x.Name == "mipmap");
                var format      = (Integer)seri.Parameters.Find(x => x.Name == "format");

                for (int i = 1; i <= ((mipMapCount.Value == 0) ? 1 : mipMapCount.Value); i++)
                {
                    settings = new ImageSettings
                    {
                        Width   = width.Value,
                        Height  = height.Value,
                        Format  = Support.Format[format.Value],
                        Swizzle = new CTRSwizzle(width.Value, height.Value)
                    };

                    bmps.Add(Common.Load(br.ReadBytes(width.Value * height.Value * Support.Format[format.Value].BitDepth / 8), settings));

                    width.Value  /= 2;
                    height.Value /= 2;
                }
            }
        }
示例#2
0
文件: TEXI.cs 项目: SeeMirra/Kuriimu
        public TEXI(Stream input, Stream texi)
        {
            using (var br = new BinaryReaderX(input))
            {
                seri = (SERIList) new XmlSerializer(typeof(SERIList)).Deserialize(XmlReader.Create(texi));

                var width       = (Integer)seri.Parameters.Find(x => x.Name == "w");
                var height      = (Integer)seri.Parameters.Find(x => x.Name == "h");
                var mipMapCount = (Integer)seri.Parameters.Find(x => x.Name == "mipmap");
                var format      = (Integer)seri.Parameters.Find(x => x.Name == "format");

                for (int i = 1; i <= ((mipMapCount.Value == 0) ? 1 : mipMapCount.Value); i++)
                {
                    var settings = new ImageSettings
                    {
                        Width         = width.Value,
                        Height        = height.Value,
                        Format        = ImageSettings.ConvertFormat((Format)format.Value),
                        PadToPowerOf2 = false
                    };

                    bmps.Add(Common.Load(br.ReadBytes(width.Value * height.Value * Common.GetBitDepth(ImageSettings.ConvertFormat((Format)format.Value)) / 8), settings));

                    width.Value  /= 2;
                    height.Value /= 2;
                }
            }
        }