Example #1
0
 public override ArcFile TryOpen(ArcView file)
 {
     if (!file.View.AsciiEqual(4, "X200"))
     {
         return(null);
     }
     using (var gal = file.CreateStream())
     {
         var info = GalXFormat.ReadMetaData(gal) as GalXMetaData;
         if (null == info || !IsSaneCount(info.FrameCount))
         {
             return(null);
         }
         var base_name = Path.GetFileNameWithoutExtension(file.Name);
         gal.Position = info.DataOffset;
         var dir = new List <Entry> (info.FrameCount);
         foreach (XmlNode node in info.FrameXml.SelectNodes("Frame"))
         {
             var layers = node.SelectSingleNode("Layers");
             var entry  = new GalXEntry {
                 Name   = string.Format("{0}#{1:D4}", base_name, dir.Count),
                 Type   = "image",
                 Offset = gal.Position,
                 Layers = layers,
                 Info   = info,
             };
             var nodes = layers.SelectNodes("Layer");
             entry.AlphaOn = nodes.Count > 0 && nodes[0].Attributes["AlphaOn"].Value != "0";
             foreach (XmlNode layer in nodes)
             {
                 bool alpha_on   = layer.Attributes["AlphaOn"].Value != "0";
                 uint layer_size = gal.ReadUInt32();
                 gal.Seek(layer_size, SeekOrigin.Current);
                 if (alpha_on)
                 {
                     uint alpha_size = gal.ReadUInt32();
                     gal.Seek(alpha_size, SeekOrigin.Current);
                 }
             }
             entry.Size = (uint)(gal.Position - entry.Offset);
             dir.Add(entry);
         }
         return(new ArcFile(file, this, dir));
     }
 }
Example #2
0
 public GalXDecoder(IBinaryStream input, GalXEntry entry) : base(input, entry.Info, 0)
 {
     m_frames.Add(GetFrameFromLayers(entry.Layers));
     m_alpha_on = entry.AlphaOn;
 }