Beispiel #1
0
        public byte[] GetFrame(GanEntry entry)
        {
            int index = entry.Index;

            if (Frames[index] != null)
            {
                return(Frames[index]);
            }

            byte[] ref_frame = null;
            if (entry.Ref != 0)
            {
                var ref_entry = Dir.Cast <GanEntry>().FirstOrDefault(e => e.Id == entry.Ref);
                if (ref_entry != null && ref_entry != entry)
                {
                    ref_frame = GetFrame(ref_entry);
                }
            }
            using (var stream = File.CreateStream(entry.Offset, entry.Size))
            {
                byte[] pixels;
                if (ref_frame != null)
                {
                    pixels = ref_frame.Clone() as byte[];
                    UnpackRefFrame(stream, pixels);
                }
                else
                {
                    pixels = new byte[(int)Info.Width * (int)Info.Height * 3];
                    UnpackKeyFrame(stream, pixels);
                }
                Frames[index] = pixels;
                return(pixels);
            }
        }