Ejemplo n.º 1
0
            public override void Dispose()
            {
                ImageFrame <TImageSharpPixel>?image = _image;

                if (image is null)
                {
                    return;
                }
                IMemoryGroup <TImageSharpPixel> memoryGroup = image.GetPixelMemoryGroup();
                long totalLength = memoryGroup.TotalLength;

                // Copy pixels into this column
                int width    = image.Width;
                int start    = _start;
                int end      = start + _length;
                int colIndex = _colIndex;
                int index    = 0;
                Span <TImageSharpPixel> sourceSpan = MemoryMarshal.Cast <byte, TImageSharpPixel>(_buffer.AsSpan(0, _length * Unsafe.SizeOf <TTiffPixel>()));

                for (int rowIndex = start; rowIndex < end; rowIndex++)
                {
                    GetBoundedSlice(memoryGroup, totalLength, rowIndex * (long)width, width)[colIndex] = sourceSpan[index++];
                }

                _image = null;
                if (_parent != null)
                {
                    ImageSharpPixelBufferWriter <TImageSharpPixel, TTiffPixel> parent = _parent;
                    _parent = null;
                    if (Interlocked.CompareExchange(ref parent._cachedColHandle, this, null) != null)
                    {
                        ReleaseBuffer();
                    }
                }
            }
Ejemplo n.º 2
0
 internal void SetHandle(ImageSharpPixelBufferWriter <TImageSharpPixel, TTiffPixel> parent, ImageFrame <TImageSharpPixel> image, int rowIndex, int start, int length)
 {
     _parent   = parent;
     _image    = image;
     _rowIndex = rowIndex;
     _start    = start;
     _length   = length;
 }
Ejemplo n.º 3
0
            internal void SetHandle(ImageSharpPixelBufferWriter <TImageSharpPixel, TTiffPixel> parent, ImageFrame <TImageSharpPixel> image, int colIndex, int start, int length)
            {
                _parent   = parent;
                _image    = image;
                _colIndex = colIndex;
                _start    = start;
                _length   = length;

                EnsureBufferSize(_length * Unsafe.SizeOf <TTiffPixel>());
            }
Ejemplo n.º 4
0
 public override void Dispose()
 {
     _image = null;
     if (_parent != null)
     {
         ImageSharpPixelBufferWriter <TImageSharpPixel, TTiffPixel> parent = _parent;
         _parent = null;
         Interlocked.CompareExchange(ref parent._cachedRowHandle, this, null);
     }
 }