Exemple #1
0
 /// <summary>
 /// Update surface to new bitmap
 /// </summary>
 /// <param name="bmp">Bitmap which used to update surface</param>
 public void UpdateFromBitmap(Bitmap bmp)
 {
     if (pendingUpdateIndexs != null && LastFrame != null)
     {
         foreach (TileIndex index in pendingUpdateIndexs)
         {
             LastFrame.UpdateTileRgb(index, CurrentFrame.GetRgbTile(index));
         }
     }
     else
     {
         LastFrame = CurrentFrame;
     }
     CurrentFrame        = SurfaceFrame.GetFromImage(Id, bmp);
     pendingUpdateIndexs = CurrentFrame.GetAllIndexes();
 }
Exemple #2
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());
        }
Exemple #3
0
 /// <summary>
 /// Get the RGB data of this tile
 /// </summary>
 /// <returns>The RGB tile</returns>
 public RgbTile GetRgb()
 {
     return(NewFrame.GetRgbTile(Index));
 }