Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Decode and Render the tile to an image
        /// </summary>
        /// <returns>The image rendered from tile</returns>
        public Bitmap ToImage()
        {
            Bitmap tileImg = new Bitmap(RdpegfxTileUtils.TileSize, RdpegfxTileUtils.TileSize);

            RfxProgressiveCodecContext codecContext = new RfxProgressiveCodecContext(this.CodecQuantVals, this.QuantIdxY, this.QuantIdxCb, this.QuantIdxCr, UseReduceExtrapolate);

            codecContext.YComponent  = new short[Y_DwtQ.Length];
            codecContext.CbComponent = new short[Cb_DwtQ.Length];
            codecContext.CrComponent = new short[Cr_DwtQ.Length];

            Y_DwtQ.CopyTo(codecContext.YComponent, 0);
            Cb_DwtQ.CopyTo(codecContext.CbComponent, 0);
            Cr_DwtQ.CopyTo(codecContext.CrComponent, 0);

            RfxProgressiveDecoder.DecodeTileFromDwtQ(codecContext);

            BitmapData bmpData = tileImg.LockBits(new Rectangle(0, 0, tileImg.Width, tileImg.Height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            unsafe
            {
                byte *cusor = (byte *)bmpData.Scan0.ToPointer();
                for (int y = 0; y < bmpData.Height; y++)
                {
                    for (int x = 0; x < bmpData.Width; x++)
                    {
                        cusor[0] = codecContext.BSet[x, y];
                        cusor[1] = codecContext.GSet[x, y];
                        cusor[2] = codecContext.RSet[x, y];
                        cusor   += 3;
                    }
                    cusor += (bmpData.Stride - 3 * (bmpData.Width));
                }
            }
            tileImg.UnlockBits(bmpData);

            return(tileImg);
        }