/// <summary> /// Get the bitmap of a tile /// </summary> /// <param name="ti">Tile index</param> /// <returns>Tile bitmap</returns> public Bitmap GetTileBitmap(TileIndex ti) { RgbTile tl = CurrentFrame.GetRgbTile(ti); if (tl != null) { return(tl.ToImage()); } return(null); }
/// <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()); }
/// <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> /// Write the Rgb data of this surface to a bitmap /// </summary> /// <returns>Bitmap</returns> public Bitmap RgbToImage() { Bitmap surfImg = new Bitmap(this.Width, this.Height); Graphics gSurf = Graphics.FromImage(surfImg); SolidBrush bgBrush = new SolidBrush(Color.FromArgb(0, Color.Black)); gSurf.FillRectangle(bgBrush, new Rectangle(0, 0, surfImg.Width, surfImg.Height)); foreach (TileIndex index in this.rgbTileDic.Keys) { RgbTile rgbT = rgbTileDic[index]; gSurf.DrawImage(rgbT.ToImage(), index.X * RdpegfxTileUtils.TileSize, index.Y * RdpegfxTileUtils.TileSize); } gSurf.Dispose(); return(surfImg); }
/// <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 the RGB data of the specified tile. /// </summary> /// <param name="index">The index of the tile.</param> /// <param name="dwtQ">The RGB data.</param> public void UpdateTileRgb(TileIndex index, RgbTile rgbT) { if (index.X * RdpegfxTileUtils.TileSize >= this.Width || index.Y * RdpegfxTileUtils.TileSize >= this.Height) { return; } lock (rgbTileDic) { if (rgbTileDic.ContainsKey(index)) { rgbTileDic[index] = rgbT; } else { rgbTileDic.Add(index, rgbT); } } }
static void FillRgbData(RfxProgressiveCodecContext encodingContext, RgbTile rgbTile) { encodingContext.RSet = rgbTile.RSet; encodingContext.GSet = rgbTile.GSet; encodingContext.BSet = rgbTile.BSet; }