/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="id">The specified surface id.</param>
 /// <param name="w">Surface width</param>
 /// <param name="h">Surface height</param>
 public Surface(ushort id, ushort w, ushort h)
 {
     Id = id;
     Width = w;
     Height = h;
     LastFrame = null;
 }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="id">The specified surface id.</param>
 /// <param name="w">Surface width</param>
 /// <param name="h">Surface height</param>
 public Surface(ushort id, ushort w, ushort h)
 {
     Id        = id;
     Width     = w;
     Height    = h;
     LastFrame = null;
 }
示例#3
0
        /// <summary>
        /// Generate a surface from a bitmap, only update the specified tiles
        /// </summary>
        /// <param name="sId">The surface Id</param>
        /// <param name="bm">The original bitmap</param>
        /// <param name="changedTileIndexs">The indexes of the changed tiles</param>
        /// <returns>A surface instance</returns>
        public static SurfaceFrame GetFromImage(ushort sId, Bitmap bitmap, TileIndex[] changedTileIndexs)
        {
            SurfaceFrame surf = new SurfaceFrame(sId, (ushort)bitmap.Width, (ushort)bitmap.Height);

            foreach (TileIndex tIndex in changedTileIndexs)
            {
                RgbTile rgbTl = RgbTile.GetFromImage(bitmap, tIndex.X * RdpegfxTileUtils.TileSize, tIndex.Y * RdpegfxTileUtils.TileSize);
                surf.rgbTileDic.Add(tIndex, rgbTl);
            }
            return(surf);
        }
示例#4
0
        /// <summary>
        /// Decode the encoded data to surface
        /// </summary>
        /// <param name="tileDic">The dictionary of tile index and encoded tile data</param>
        public void ProgressiveDecode(Dictionary <TileIndex, EncodedTile> tileDic)
        {
            if (this.CurrentFrame == null)
            {
                this.CurrentFrame = SurfaceFrame.GetFromImage(this.Id, new Bitmap(this.Width, this.Height));
            }

            foreach (TileIndex index in tileDic.Keys)
            {
                TileState tState = new TileState(this, index);
                RfxProgressiveDecoder.DecodeTile(tileDic[index], tState);
            }
        }
示例#5
0
        /// <summary>
        /// Generate a surface from a bitmap
        /// </summary>
        /// <param name="sId">The surface Id</param>
        /// <param name="bm">The original bitmap</param>
        /// <returns>A surface instance</returns>
        public static SurfaceFrame GetFromImage(ushort sId, Bitmap bitmap)
        {
            SurfaceFrame surf = new SurfaceFrame(sId, (ushort)bitmap.Width, (ushort)bitmap.Height);

            for (int xIndex = 0; xIndex *RdpegfxTileUtils.TileSize < bitmap.Width; xIndex++)
            {
                for (int yIndex = 0; yIndex *RdpegfxTileUtils.TileSize < bitmap.Height; yIndex++)
                {
                    TileIndex tIndex = new TileIndex((ushort)xIndex, (ushort)yIndex, bitmap.Width, bitmap.Height);

                    RgbTile rgbTl = RgbTile.GetFromImage(bitmap, xIndex * RdpegfxTileUtils.TileSize, yIndex * RdpegfxTileUtils.TileSize);
                    surf.rgbTileDic.Add(tIndex, rgbTl);
                }
            }
            return(surf);
        }
示例#6
0
 /// <summary>
 /// Update surface from the changed area of the bitmap frame
 /// </summary>
 /// <param name="bmp">Bitmap which used to update surface</param>
 /// <param name="changedArea">The changed areas</param>
 public void UpdateFromBitmap(Bitmap bmp, Rectangle[] changedAreas)
 {
     if (pendingUpdateIndexs != null && LastFrame != null)
     {
         foreach (TileIndex index in pendingUpdateIndexs)
         {
             LastFrame.UpdateTileRgb(index, CurrentFrame.GetRgbTile(index));
         }
     }
     else
     {
         LastFrame = CurrentFrame;
     }
     pendingUpdateIndexs = this.GetIndexesInRect(changedAreas);
     CurrentFrame        = SurfaceFrame.GetFromImage(Id, bmp, pendingUpdateIndexs);
 }
示例#7
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();
 }
        /// <summary>
        /// Generate a surface from a bitmap, only update the specified tiles
        /// </summary>
        /// <param name="sId">The surface Id</param>
        /// <param name="bm">The original bitmap</param>
        /// <param name="changedTileIndexs">The indexes of the changed tiles</param>
        /// <returns>A surface instance</returns>
        public static SurfaceFrame GetFromImage(ushort sId, Bitmap bitmap, TileIndex[] changedTileIndexs)
        {
            SurfaceFrame surf = new SurfaceFrame(sId, (ushort)bitmap.Width, (ushort)bitmap.Height);

            foreach (TileIndex tIndex in changedTileIndexs)
            {
                RgbTile rgbTl = RgbTile.GetFromImage(bitmap, tIndex.X * RdpegfxTileUtils.TileSize, tIndex.Y * RdpegfxTileUtils.TileSize);
                surf.rgbTileDic.Add(tIndex, rgbTl);
            }
            return surf;
        }
        /// <summary>
        /// Generate a surface from a bitmap
        /// </summary>
        /// <param name="sId">The surface Id</param>
        /// <param name="bm">The original bitmap</param>
        /// <returns>A surface instance</returns>
        public static SurfaceFrame GetFromImage(ushort sId, Bitmap bitmap)
        {
            SurfaceFrame surf = new SurfaceFrame(sId, (ushort)bitmap.Width, (ushort)bitmap.Height);
            for (int xIndex = 0; xIndex * RdpegfxTileUtils.TileSize < bitmap.Width; xIndex++)
            {
                for (int yIndex = 0; yIndex * RdpegfxTileUtils.TileSize < bitmap.Height; yIndex++)
                {
                    TileIndex tIndex = new TileIndex((ushort)xIndex, (ushort)yIndex, bitmap.Width, bitmap.Height);

                    RgbTile rgbTl = RgbTile.GetFromImage(bitmap, xIndex * RdpegfxTileUtils.TileSize, yIndex * RdpegfxTileUtils.TileSize);
                    surf.rgbTileDic.Add(tIndex, rgbTl);
                }
            }
            return surf;
        }
 /// <summary>
 /// Update surface from the changed area of the bitmap frame
 /// </summary>
 /// <param name="bmp">Bitmap which used to update surface</param>
 /// <param name="changedArea">The changed areas</param>
 public void UpdateFromBitmap(Bitmap bmp, Rectangle[] changedAreas)
 {
     if (pendingUpdateIndexs != null && LastFrame !=null)
     {
         foreach (TileIndex index in pendingUpdateIndexs)
         {
             LastFrame.UpdateTileRgb(index, CurrentFrame.GetRgbTile(index));
         }
     }
     else
     {
         LastFrame = CurrentFrame;
     }
     pendingUpdateIndexs = this.GetIndexesInRect(changedAreas);
     CurrentFrame = SurfaceFrame.GetFromImage(Id, bmp, pendingUpdateIndexs);
 }
 /// <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();
 }
        /// <summary>
        /// Decode the encoded data to surface
        /// </summary>
        /// <param name="tileDic">The dictionary of tile index and encoded tile data</param>
        public void ProgressiveDecode(Dictionary<TileIndex, EncodedTile> tileDic)
        {
            if (this.CurrentFrame == null)
            {
                this.CurrentFrame = SurfaceFrame.GetFromImage(this.Id, new Bitmap(this.Width, this.Height));
            }

            foreach (TileIndex index in tileDic.Keys)
            {
                TileState tState = new TileState(this, index);
                RfxProgressiveDecoder.DecodeTile(tileDic[index], tState);
            }
        }
示例#13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="newFrame">The current frame contains this tile</param>
 /// <param name="index">The index of this tile in surface</param>
 public TileState(SurfaceFrame newFrame, TileIndex index)
 {
     NewFrame = newFrame;
     Index    = index;
 }
示例#14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="surface">The surface contains this tile</param>
 /// <param name="index">The index of this tile in surface</param>
 public TileState(Surface surface, TileIndex index)
 {
     NewFrame  = surface.CurrentFrame;
     LastFrame = surface.LastFrame;
     Index     = index;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="newFrame">The current frame contains this tile</param>
 /// <param name="index">The index of this tile in surface</param>
 public TileState(SurfaceFrame newFrame, TileIndex index)
 {
     NewFrame = newFrame;
     Index = index;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="surface">The surface contains this tile</param>
 /// <param name="index">The index of this tile in surface</param>
 public TileState(Surface surface, TileIndex index)
 {
     NewFrame = surface.CurrentFrame;
     LastFrame = surface.LastFrame;
     Index = index;
 }