コード例 #1
0
        private DrawGroupImg LoadImage(int Index)
        {
            DrawGroupImg Img = m_Images[Index];

            Img.CompileSprites();

            return(Img);
        }
コード例 #2
0
        /// <summary>
        /// The DGRP chunk is used to combine multiple sprites into one object.
        /// </summary>
        /// <param name="ChunkData">The data for the chunk.</param>
        /// <param name="Sprites">The sprites that the DGRP consists of.</param>
        public DrawGroup(IffChunk Chunk, List <SPR2Parser> Sprites) : base(Chunk)
        {
            MemoryStream MemStream = new MemoryStream(Chunk.Data);
            BinaryReader Reader    = new BinaryReader(MemStream);

            m_ID      = ID;
            m_Sprites = Sprites;

            //Reader.BaseStream.Position = INDEX_VERSION;
            m_Version = Reader.ReadUInt16() - 20000;

            uint Count = (m_Version < 3) ? Reader.ReadUInt16() : Reader.ReadUInt32();
            uint SpriteCount, DirectionFlag, Zoom;

            for (int i = 0; i < Count; i++)
            {
                if (m_Version < 3)
                {
                    SpriteCount   = Reader.ReadUInt16();
                    DirectionFlag = Reader.ReadByte();
                    Zoom          = Reader.ReadByte();
                }
                else
                {
                    DirectionFlag = Reader.ReadUInt32();
                    Zoom          = Reader.ReadUInt32();
                    SpriteCount   = Reader.ReadUInt32();
                }
                DrawGroupImg Image = new DrawGroupImg(SpriteCount, DirectionFlag, Zoom);

                for (int j = 0; j < SpriteCount; j++)
                {
                    ushort Tag = 0;
                    int    PixelX = 0, PixelY = 0;
                    uint   SprID = 0, SprFrameID = 0, Flags = 0;
                    float  ZOffset = 0, XOffset = 0, YOffset = 0;

                    if (m_Version < 3)
                    {
                        Tag        = Reader.ReadUInt16();
                        SprID      = Reader.ReadUInt16();
                        SprFrameID = Reader.ReadUInt16();
                        Flags      = Reader.ReadUInt16();
                        PixelX     = Reader.ReadInt16();
                        PixelY     = Reader.ReadInt16();

                        if (m_Version == 1)
                        {
                            ZOffset = Reader.ReadUInt32();
                        }
                    }
                    else
                    {
                        SprID      = Reader.ReadUInt32();
                        SprFrameID = Reader.ReadUInt32();
                        PixelX     = Reader.ReadInt32();
                        PixelY     = Reader.ReadInt32();
                        ZOffset    = Reader.ReadUInt32();
                        Flags      = Reader.ReadUInt32();
                        if (m_Version == 4)
                        {
                            XOffset = Reader.ReadUInt32();
                            YOffset = Reader.ReadUInt32();
                        }
                    }

                    SpriteFrame Frame = FindSpriteFrame(SprID, SprFrameID);
                    if (Frame != null)
                    {
                        DrawGroupSprite Sprite = new DrawGroupSprite(Tag, Flags, new PixelOffset(PixelX, PixelY),
                                                                     new WorldOffset(XOffset, YOffset, ZOffset), Frame);
                        Image.Sprites.Insert(0, Sprite);
                    }
                }

                //Image.CompileSprites();
                m_Images.Add(Image);
            }
        }
コード例 #3
0
        public DrawGroup(byte[] ChunkData, List <SpriteParser> Sprites)
        {
            MemoryStream MemStream = new MemoryStream(ChunkData);
            BinaryReader Reader    = new BinaryReader(MemStream);

            Reader.BaseStream.Position = INDEX_VERSION;
            m_Version = Reader.ReadUInt16() - 20000;

            uint         Count = (m_Version < 3) ? Reader.ReadUInt16() : Reader.ReadUInt32();
            uint         SpriteCount;
            DrawGroupImg Img;

            for (int i = 0; i < Count; i++)
            {
                if (m_Version < 3)
                {
                    SpriteCount = Reader.ReadUInt16();
                    ushort DirectionFlag = Reader.ReadUInt16();
                    ushort Zoom          = Reader.ReadUInt16();

                    Img            = new DrawGroupImg(DirectionFlag, Zoom);
                    Img.BitmapData = new Bitmap(136, 184);
                }
                else
                {
                    uint DirectionFlag = Reader.ReadUInt32();
                    uint Zoom          = Reader.ReadUInt32();
                    SpriteCount = Reader.ReadUInt32();

                    m_Img            = new DrawGroupImg(DirectionFlag, Zoom);
                    m_Img.BitmapData = new Bitmap(136, 384);
                }

                for (int j = 0; j < SpriteCount; j++)
                {
                    uint Tag, SprID, SprFrameID, Flags, PixelX, PixelY, ZOffset, XOffset, YOffset;

                    if (m_Version < 3)
                    {
                        SprID      = Reader.ReadUInt16();
                        Tag        = Reader.ReadUInt16();
                        SprFrameID = Reader.ReadUInt16();
                        Flags      = Reader.ReadUInt16();
                        PixelX     = Reader.ReadUInt16();
                        PixelY     = Reader.ReadUInt16();

                        if (m_Version == 1)
                        {
                            ZOffset = Reader.ReadUInt16();
                        }
                    }
                    else
                    {
                        SprID = Reader.ReadUInt32();
                        Reader.BaseStream.Position = +3;
                        SprFrameID = Reader.ReadUInt32();
                        PixelX     = Reader.ReadUInt32();
                        PixelY     = Reader.ReadUInt32();
                        ZOffset    = Reader.ReadUInt32();
                        Flags      = Reader.ReadUInt32();
                        XOffset    = Reader.ReadUInt32();
                        YOffset    = Reader.ReadUInt32();
                    }

                    foreach (SpriteParser Sprite in Sprites)
                    {
                        if (Sprite.ID == SprID)
                        {
                            SpriteFrame Frame = Sprite.GetFrame((int)SprFrameID);

                            if (Frame != null)
                            {
                                RectangleF Rect = new RectangleF(Frame.XLocation, Frame.YLocation, Frame.Width, Frame.Height);
                                m_Img.BitmapData.Clone(Rect, Frame.BitmapData.PixelFormat);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: DrawGroup.cs プロジェクト: ddfczm/Project-Dollhouse
        public DrawGroup(byte[] ChunkData, List<SpriteParser> Sprites)
        {
            MemoryStream MemStream = new MemoryStream(ChunkData);
            BinaryReader Reader = new BinaryReader(MemStream);

            Reader.BaseStream.Position = INDEX_VERSION;
            m_Version = Reader.ReadUInt16() - 20000;

            uint Count = (m_Version < 3) ? Reader.ReadUInt16() : Reader.ReadUInt32();
            uint SpriteCount;
            DrawGroupImg Img;

            for (int i = 0; i < Count; i++)
            {
                if (m_Version < 3)
                {
                    SpriteCount = Reader.ReadUInt16();
                    ushort DirectionFlag = Reader.ReadUInt16();
                    ushort Zoom = Reader.ReadUInt16();

                    Img = new DrawGroupImg(DirectionFlag, Zoom);
                    Img.BitmapData = new Bitmap(136, 184);
                }
                else
                {
                    uint DirectionFlag = Reader.ReadUInt32();
                    uint Zoom = Reader.ReadUInt32();
                    SpriteCount = Reader.ReadUInt32();

                    m_Img = new DrawGroupImg(DirectionFlag, Zoom);
                    m_Img.BitmapData = new Bitmap(136, 384);
                }

                for (int j = 0; j < SpriteCount; j++)
                {
                    uint Tag, SprID, SprFrameID, Flags, PixelX, PixelY, ZOffset, XOffset, YOffset;

                    if (m_Version < 3)
                    {
                        SprID = Reader.ReadUInt16();
                        Tag = Reader.ReadUInt16();
                        SprFrameID = Reader.ReadUInt16();
                        Flags = Reader.ReadUInt16();
                        PixelX = Reader.ReadUInt16();
                        PixelY = Reader.ReadUInt16();

                        if (m_Version == 1)
                            ZOffset = Reader.ReadUInt16();
                    }
                    else
                    {
                        SprID = Reader.ReadUInt32();
                        Reader.BaseStream.Position =+ 3;
                        SprFrameID = Reader.ReadUInt32();
                        PixelX = Reader.ReadUInt32();
                        PixelY = Reader.ReadUInt32();
                        ZOffset = Reader.ReadUInt32();
                        Flags = Reader.ReadUInt32();
                        XOffset = Reader.ReadUInt32();
                        YOffset = Reader.ReadUInt32();
                    }

                    foreach (SpriteParser Sprite in Sprites)
                    {
                        if (Sprite.ID == SprID)
                        {
                            SpriteFrame Frame = Sprite.GetFrame((int)SprFrameID);

                            if (Frame != null)
                            {
                                RectangleF Rect = new RectangleF(Frame.XLocation, Frame.YLocation, Frame.Width, Frame.Height);
                                m_Img.BitmapData.Clone(Rect, Frame.BitmapData.PixelFormat);
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// The DGRP chunk is used to combine multiple sprites into one object.
        /// </summary>
        /// <param name="ChunkData">The data for the chunk.</param>
        /// <param name="Sprites">The sprites that the DGRP consists of.</param>
        public DrawGroup(IffChunk Chunk, List<SPR2Parser> Sprites)
            : base(Chunk)
        {
            MemoryStream MemStream = new MemoryStream(Chunk.Data);
            BinaryReader Reader = new BinaryReader(MemStream);

            m_ID = ID;
            m_Sprites = Sprites;

            //Reader.BaseStream.Position = INDEX_VERSION;
            m_Version = Reader.ReadUInt16() - 20000;

            uint Count = (m_Version < 3) ? Reader.ReadUInt16() : Reader.ReadUInt32();
            uint SpriteCount, DirectionFlag, Zoom;

            for (int i = 0; i < Count; i++)
            {
                if (m_Version < 3)
                {
                    SpriteCount = Reader.ReadUInt16();
                    DirectionFlag = Reader.ReadByte();
                    Zoom = Reader.ReadByte();
                }
                else
                {
                    DirectionFlag = Reader.ReadUInt32();
                    Zoom = Reader.ReadUInt32();
                    SpriteCount = Reader.ReadUInt32();
                }
                DrawGroupImg Image = new DrawGroupImg(SpriteCount, DirectionFlag, Zoom);

                for (int j = 0; j < SpriteCount; j++)
                {
                    ushort Tag = 0;
                    int PixelX = 0, PixelY = 0;
                    uint SprID = 0, SprFrameID = 0, Flags = 0;
                    float ZOffset = 0, XOffset = 0, YOffset = 0;

                    if (m_Version < 3)
                    {
                        Tag = Reader.ReadUInt16();
                        SprID = Reader.ReadUInt16();
                        SprFrameID = Reader.ReadUInt16();
                        Flags = Reader.ReadUInt16();
                        PixelX = Reader.ReadInt16();
                        PixelY = Reader.ReadInt16();

                        if (m_Version == 1)
                            ZOffset = Reader.ReadUInt32();
                    }
                    else
                    {
                        SprID = Reader.ReadUInt32();
                        SprFrameID = Reader.ReadUInt32();
                        PixelX = Reader.ReadInt32();
                        PixelY = Reader.ReadInt32();
                        ZOffset = Reader.ReadUInt32();
                        Flags = Reader.ReadUInt32();
                        if (m_Version == 4)
                        {
                            XOffset = Reader.ReadUInt32();
                            YOffset = Reader.ReadUInt32();
                        }
                    }

                    SpriteFrame Frame = FindSpriteFrame(SprID, SprFrameID);
                    if (Frame != null)
                    {
                        DrawGroupSprite Sprite = new DrawGroupSprite(Tag, Flags, new PixelOffset(PixelX, PixelY),
                            new WorldOffset(XOffset, YOffset, ZOffset), Frame);
                        Image.Sprites.Insert(0, Sprite);
                    }
                }

                //Image.CompileSprites();
                m_Images.Add(Image);
            }
        }