public void Save(Stream Output)
        {
            Core.Motion.ANI ANI = new Core.Motion.ANI();

            var header = new Core.Motion.ANIHEADER();

            header.iDispRate    = FrameRate;
            header.nFrames      = (ushort)this.Frames.Count;
            header.nSteps       = (ushort)this.Frames.Count;
            header.nPlanes      = 1;
            header.iBitCount    = 32;
            header.bfAttributes = 1;
            ANI.Header          = header;

            ANI.IART = Author;
            ANI.INAM = Name;

            foreach (BitmapFrame frame in Frames)
            {
                CursorBitmapEncoder enc = new CursorBitmapEncoder();
                enc.Frames.Add(frame);
                enc.SetHotspot(frame, GetHotspot(frame)[0], GetHotspot(frame)[1]);
                MemoryStream encStream = new MemoryStream();
                enc.Save(encStream);
                ANI.Frames.Add(encStream.ToArray());
            }
            ANI.Write(Output);
        }
Exemplo n.º 2
0
        public void Open(Stream Source)
        {
            //Note that, each frame of ani file might be a full (.cur) cursor file or a full (.ico) icon file or even
            //a Bitmap file;
            //I'm guessing that you are luckly enought to be opening a ANI file that has its frames
            //encoded .ico ;)
            Core.Motion.ANI ani = new Core.Motion.ANI();
            ani.Load(Source);
            _Name      = ani.INAM;
            _Author    = ani.IART;
            _FrameRate = ani.Header.iDispRate;

            foreach (byte[] frame in ani.Frames)
            {
                CursorBitmapDecoder decoder = new CursorBitmapDecoder();
                decoder.Open(new MemoryStream(frame));
                foreach (var f in decoder.Frames)
                {
                    this._Frames.Add(f);
                    var hotspot = decoder.GetHotspot(f);
                    SetHotspot(f, hotspot[0], hotspot[1]);
                }
            }
        }