Ejemplo n.º 1
0
 public void DereferenceFrom(Cel linkTarget)
 {
     this.X           = linkTarget.X;
     this.Y           = linkTarget.Y;
     this.Width       = linkTarget.Width;
     this.Height      = linkTarget.Height;
     this.ColorBuffer = linkTarget.ColorBuffer;
     this.Opacity     = linkTarget.Opacity;
     this.UserData    = linkTarget.UserData;
 }
Ejemplo n.º 2
0
        static IUserDataAcceptor ParseCel(AseFile file, ColorType colorType,
                                          BinaryReader reader, int chunkBytes, Frame frame)
        {
            var layerIndex = reader.ReadWord();          // 2
            var x          = reader.ReadInt16();         // 2
            var y          = reader.ReadInt16();         // 2
            var opacity    = reader.ReadByte() / 255.0f; // 1
            var type       = (CelType)reader.ReadWord(); // 2

            reader.ReadBytes(7);                         // 7

            Cel cel;

            switch (type)
            {
            case CelType.Raw:
            {
                var celWidth    = reader.ReadWord(); // 2
                var celHeight   = reader.ReadWord(); // 2
                var colorBuffer = ToColorBuffer(colorType, reader.ReadBytes(chunkBytes - 6 - 16 - 4));
                cel = new Cel(x, y, celWidth, celHeight, colorBuffer, layerIndex, opacity);
                break;
            }

            case CelType.Linked:
            {
                var linkedFrame = reader.ReadWord();
                cel = new Cel(linkedFrame, layerIndex);
                break;
            }

            case CelType.Compressed:
            {
                var celWidth    = reader.ReadWord();
                var celHeight   = reader.ReadWord();
                var colorBuffer = ToColorBuffer(colorType, reader.ReadCompressedBytes(chunkBytes - 6 - 16 - 4));
                cel = new Cel(x, y, celWidth, celHeight, colorBuffer, layerIndex, opacity);
                break;
            }

            default:
            {
                throw new ArgumentException();
            }
            }

            if (file.FindLayer(cel.LayerIndex) != null)
            {
                frame.AddCel(cel);
            }

            return(cel);
        }
Ejemplo n.º 3
0
 public bool TryGetCel(int layer, out Cel cel)
 {
     return(cels.TryGetValue(layer, out cel));
 }
Ejemplo n.º 4
0
 public void AddCel(Cel cel)
 {
     cels.Add(cel.LayerIndex, cel);
 }