private static Bgra32ImageBuffer ReadImage(OpenSlideImage image, string name) { if (!image.TryGetAssociatedImageDimensions(name, out var dims)) { throw new KeyNotFoundException(); } return(image.ReadAssociatedImageBuffer(name, dims.Width, dims.Height)); }
private static Image <Bgra32> WriteImage(OpenSlideImage image, string name) { if (!image.TryGetAssociatedImageDimensions(name, out var dims)) { throw new KeyNotFoundException(); } var dest = new Image <Bgra32>((int)dims.Width, (int)dims.Height); image.ReadAssociatedImage(name, ref Unsafe.As <Bgra32, byte>(ref MemoryMarshal.GetReference(dest.GetPixelSpan()))); return(dest); }
private static Image <Bgra32> WriteImage(OpenSlideImage image, string name) { if (!image.TryGetAssociatedImageDimensions(name, out var dims)) { throw new KeyNotFoundException(); } var dest = new Image <Bgra32>((int)dims.Width, (int)dims.Height); var frame = dest.Frames.RootFrame; image.DangerousReadAssociatedImage(name, ref Unsafe.As <Bgra32, byte>(ref frame.DangerousGetPinnableReferenceToPixelBuffer())); return(dest); }