Repository navigation
Dapplo.Windows 3.9.2
Read large bitmaps from the clipboard with fewer full-size copies.
Added
DibImage.TryReadInfo(ReadOnlySpan<byte> dib, long maxPixelCount, out int width, out int height, out bool hasAlpha): validates the header exactly likeTryDecodeand tells the size and whether the decoded image would have alpha (for 32 bpp from the alpha values of the pixels), without decoding or allocating the pixels.DibImage.TryDecode(ReadOnlySpan<byte> dib, long maxPixelCount, Span<byte> destination, int destinationStride): decodes into memory of the caller (e.g. a locked bitmap), the same top-down BGRA32 pixels with straight alpha asDibImage.Pixels; false for invalid data or a destination which is too small. The padding of a larger stride is not written.
Changed
- The read-only
MemoryStreams ofClipboardSnapshot.TryGetStreamand ofDataObjectReaderare publicly visible, soMemoryStream.TryGetBufferreturns their array without a copy (still not writable; don't change the buffer, it is the snapshot's data). - The DIB decoder is split into header parsing and decoding into a span;
DibImage.TryDecode(byte[] ...)uses it, its results are unchanged. The palette and the check for repeated masks no longer allocate.