Ghostscript.NET.Viewer.GhostscriptViewerImage.Unlock C# (CSharp) Method

Unlock() private method

private Unlock ( ) : void
return void
        internal void Unlock()
        {
            if (_bitmapData != null)
            {
                _bitmap.UnlockBits(_bitmapData);
                _bitmapData = null;
            }
        }

Usage Example

コード例 #1
0
        public override int Update(IntPtr handle, IntPtr device, int x, int y, int w, int h)
        {
            int bytesPerPixel = 3; // for now Format24bppRgb only

            if (_srcImage != IntPtr.Zero)
            {
                _destImage.Lock();

                int destStrideSize = (((_destImage.Width * bytesPerPixel) + 3) & ~3);
                int tileStride     = (((w * bytesPerPixel) + 3) & ~3);

                if (_synchTriggered)
                {
                    _synchTriggered = false;

                    ImageMemoryHelper.Set24bppRgbImageColor(_destImage.Scan0, _destImage.Width, _destImage.Height, 255, 255, 255);
                }

                if (w == _destImage.Width && h == _destImage.Height)
                {
                    //IntPtr bkp = Marshal.AllocCoTaskMem(destStrideSize * h);

                    //ImageMemoryHelper.CopyImagePartFrom(_destImage.Scan0, bkp, 0, 0, w, h, destStrideSize, bytesPerPixel);
                    //ImageMemoryHelper.CopyImagePartTo(_destImage.Scan0, _srcImage, 0, 0, w, h, destStrideSize, bytesPerPixel);
                    //ImageMemoryHelper.CopyImagePartTo(_destImage.Scan0, bkp, 0, 0, w, h, destStrideSize, bytesPerPixel);

                    //Marshal.FreeCoTaskMem(bkp);

                    _destImage.Unlock();

                    return(0);
                }

                IntPtr tempTile = Marshal.AllocCoTaskMem(tileStride * h);

                ImageMemoryHelper.CopyImagePartFrom(_srcImage, tempTile, x, y, w, h, _srcStride, bytesPerPixel);

                ImageMemoryHelper.FlipImageVertically(tempTile, tempTile, h, tileStride);

                int tileMirrorY = _destImage.Height - y - h;

                ImageMemoryHelper.CopyImagePartTo(_destImage.Scan0, tempTile, x, tileMirrorY, w, h, destStrideSize, bytesPerPixel);

                Marshal.FreeCoTaskMem(tempTile);

                _destImage.Unlock();

                if (Environment.TickCount - _lastUpdateTime > _viewer.ProgressiveUpdateInterval)
                {
                    _lastUpdateTime = Environment.TickCount;

                    _viewer.RaiseDisplayUpdate(new GhostscriptViewerViewEventArgs(_destImage, new Rectangle(0, 0, _destImage.Width, _destImage.Height)));
                }
            }

            return(0);
        }
All Usage Examples Of Ghostscript.NET.Viewer.GhostscriptViewerImage::Unlock