BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
ImageSeriesLoader.cs
Go to the documentation of this file.
1namespace BioCore
2{
3 internal static class ImageSeriesLoader
4 {
5 internal static async IAsyncEnumerable<BioImage> OpenAsync(string file)
6 {
7 int count = BioImage.GetSeriesCount(file);
8 for (int series = 0; series < count;)
9 {
10 BioImage image = await BioImage.OpenFileAsync(file, series, false, true);
11 if (image == null)
12 throw new InvalidOperationException("The image loader returned no image.");
13
14 int seriesSpan = 1;
15 // BioLib may collect consecutive series into one pyramid. Only skip
16 // those native levels; nested and synthetic resolutions consume no series.
17 if (image.Type == BioImage.ImageType.pyramidal &&
18 image.PyramidNativeLevelCount > 1 &&
19 image.imRead != null && image.imRead.getResolutionCount() == 1)
20 {
21 seriesSpan = Math.Min(image.PyramidNativeLevelCount, count - series);
22 }
23
24 // Determine the next series before the viewer can change the reader's level.
25 series += seriesSpan;
26 yield return image;
27 }
28 }
29 }
30}