コード例 #1
0
ファイル: Texture2D.cs プロジェクト: y111303tut/GARbro
 public void Dispose()
 {
     if (!m_disposed)
     {
         m_reader.Dispose();
         m_disposed = true;
     }
 }
コード例 #2
0
        public override IImageDecoder OpenImage(ArcFile arc, Entry entry)
        {
            var aent = entry as AssetEntry;

            if (null == aent || aent.AssetObject.TypeId != 28)
            {
                return(base.OpenImage(arc, entry));
            }

            var obj    = aent.AssetObject;
            var stream = arc.File.CreateStream(obj.Offset, obj.Size);
            var reader = new AssetReader(stream);

            try
            {
                reader.SetupReaders(obj.Asset);
                var tex = new Texture2D();
                tex.Load(reader);
                if (0 == tex.m_DataLength)
                {
                    reader.Dispose();
                    var input = OpenEntry(arc, entry);
                    reader = new AssetReader(input, entry.Name);
                    reader.SetupReaders(obj.Asset);
                    tex.m_DataLength = (int)entry.Size;
                }
                var decoder = new Texture2DDecoder(tex, reader);
                reader = null;
                return(decoder);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
            }
        }