コード例 #1
0
 public override void Dispose()
 {
     _innerHandle?.Dispose();
     _innerHandle = null;
     if (_parent != null)
     {
         TiffPassthroughPixelBufferWriter <TSource, TDestination> parent = _parent;
         _parent = null;
         Interlocked.CompareExchange(ref parent._cachedHandle, this, null);
     }
 }
コード例 #2
0
            public override void Dispose()
            {
                if (_innerHandle is null)
                {
                    return;
                }

                Debug.Assert(_parent != null);
                _innerHandle.GetSpan().Reverse();
                _innerHandle.Dispose();
                TiffOrientedPixelBufferWriter <TPixel> parent = _parent !;

                _parent      = null;
                _innerHandle = null;
                Interlocked.CompareExchange(ref parent._cachedHandle, this, null);
            }
コード例 #3
0
        /// <inheritdoc />
        public ValueTask ReadAsync(TiffPoint offset, TiffPixelBufferWriter <TPixel> destination, CancellationToken cancellationToken)
        {
            if (offset.X >= (uint)_size.Width || offset.Y >= (uint)_size.Height)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }

            int width  = Math.Min(_size.Width - offset.X, destination.Width);
            int height = Math.Min(_size.Height - offset.Y, destination.Height);

            ReadOnlySpan <TPixel> buffer = _buffer.GetReadOnlySpan();
            int bufferWidth = _size.Width;

            for (int row = 0; row < height; row++)
            {
                ReadOnlySpan <TPixel> sourceSpan = buffer.Slice(bufferWidth * (offset.Y + row) + offset.X, width);
                using TiffPixelSpanHandle <TPixel> destinationHandle = destination.GetRowSpan(row);
                sourceSpan.CopyTo(destinationHandle.GetSpan());
            }

            return(default);
コード例 #4
0
        public TiffPixelSpanHandle <TPixel> GetColumnSpan(int colIndex, int start, int length)
        {
            int width = _writer.Width, height = _writer.Height;
            int rowIndex = colIndex;

            if ((uint)rowIndex >= (uint)height)
            {
                throw new ArgumentOutOfRangeException(nameof(colIndex));
            }
            if ((uint)start >= (uint)width)
            {
                throw new ArgumentOutOfRangeException(nameof(start));
            }
            if (length < 0 || (uint)(start + length) > (uint)width)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            if (_flipTopBottom)
            {
                rowIndex = height - rowIndex - 1;
            }

            if (!_flipLeftRight)
            {
                return(_writer.GetRowSpan(rowIndex, start, length));
            }

            TiffPixelSpanHandle <TPixel> innerHandle = _writer.GetRowSpan(rowIndex, width - start - length, length);
            FlippedHandle?handle = Interlocked.Exchange(ref _cachedHandle, null);

            if (handle is null)
            {
                handle = new FlippedHandle();
            }
            handle.SetHandle(this, innerHandle);
            return(handle);
        }
コード例 #5
0
 internal void SetHandle(TiffOrientedPixelBufferWriter <TPixel> parent, TiffPixelSpanHandle <TPixel> handle)
 {
     _parent      = parent;
     _innerHandle = handle;
     _length      = handle.Length;
 }
コード例 #6
0
 internal void SetHandle(TiffPassthroughPixelBufferWriter <TSource, TDestination> parent, TiffPixelSpanHandle <TDestination> handle, int length)
 {
     _parent      = parent;
     _innerHandle = handle;
     _length      = length;
 }