Exemple #1
0
        /// <summary>
        /// Get the different tiles of this surface
        /// </summary>
        /// <param name="bRgb">If true, check if Rgb data exist for specified frame; otherwise, check if Dwt data exist.</param>
        /// <returns>The array of different tiles.</returns>
        public TileIndex[] GetDiffIndexes(bool bRgb)
        {
            if (this.pendingUpdateIndexs != null && this.pendingUpdateIndexs.Length <= RdpegfxTileUtils.TileDiffMinCount)
            {
                return(this.pendingUpdateIndexs);
            }

            if (CurrentFrame == null)
            {
                return(null);
            }
            if (LastFrame == null)
            {
                return(this.pendingUpdateIndexs);
            }
            List <TileIndex> diffIndexList = new List <TileIndex>();

            for (int xIndex = 0; xIndex *RdpegfxTileUtils.TileSize < this.Width; xIndex++)
            {
                for (int yIndex = 0; yIndex *RdpegfxTileUtils.TileSize < this.Height; yIndex++)
                {
                    TileIndex tIndex = new TileIndex((ushort)xIndex, (ushort)yIndex, this.Width, this.Height);
                    if (CurrentFrame.IsIndexInScope(tIndex, bRgb))
                    {
                        //diffIndexList.Add(tIndex);
                        if (LastFrame != null && LastFrame.IsIndexInScope(tIndex, bRgb))
                        {
                            if (bRgb)
                            {
                                RgbTile prvRgb = LastFrame.GetRgbTile(tIndex);
                                RgbTile curRgb = CurrentFrame.GetRgbTile(tIndex);
                                if (!curRgb.EqualsWith(prvRgb))
                                {
                                    diffIndexList.Add(tIndex);
                                }
                            }
                            else
                            {
                                DwtTile prvDwt = LastFrame.GetDwt(tIndex);
                                DwtTile curDwt = CurrentFrame.GetDwt(tIndex);
                                if (!curDwt.EqualsWith(prvDwt))
                                {
                                    diffIndexList.Add(tIndex);
                                }
                            }
                        }
                        else
                        {
                            diffIndexList.Add(tIndex);
                        }
                    }
                }
            }
            return(diffIndexList.ToArray());
        }