public static Bgra32ImageBuffer ReadAssociatedImageBuffer(this OpenSlideImage image, string name, long w, long h) { var buffer = new Bgra32ImageBuffer(checked ((int)w), checked ((int)h)); image.ReadAssociatedImage(name, ref buffer.GetPinnableReference()); return(buffer); }
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); }