예제 #1
0
            public override void Dispose()
            {
                if (_innerHandle is null)
                {
                    return;
                }

                Debug.Assert(_parent != null);
                Span <TDestination> destinationSpan = _innerHandle.GetSpan();

                if (_useInplaceConvert)
                {
                    Span <TSource> sourceSpan = MemoryMarshal.Cast <TDestination, TSource>(destinationSpan);
                    _parent !.Convert(sourceSpan, destinationSpan);
                }
                else
                {
                    Span <TSource> sourceSpan = MemoryMarshal.Cast <byte, TSource>(_buffer.AsSpan(0, _length * Unsafe.SizeOf <TSource>()));
                    _parent !.Convert(sourceSpan, destinationSpan);
                }

                _innerHandle.Dispose();
                TiffPixelConverter <TSource, TDestination> parent = _parent;

                _parent      = null;
                _innerHandle = null;
                if (Interlocked.CompareExchange(ref parent._cachedHandle, this, null) != null)
                {
                    ReleaseBuffer();
                }
            }
예제 #2
0
            internal void SetHandle(TiffPixelConverter <TSource, TDestination> parent, TiffPixelSpanHandle <TDestination> handle, bool useInplaceConvert)
            {
                _parent            = parent;
                _innerHandle       = handle;
                _length            = handle.Length;
                _useInplaceConvert = useInplaceConvert;

                if (!useInplaceConvert)
                {
                    EnsureBufferSize(_length * Unsafe.SizeOf <TSource>());
                }
            }