LibCspCore 1.0.0
See the version list below for details.
dotnet add package LibCspCore --version 1.0.0
NuGet\Install-Package LibCspCore -Version 1.0.0
<PackageReference Include="LibCspCore" Version="1.0.0" />
<PackageVersion Include="LibCspCore" Version="1.0.0" />
<PackageReference Include="LibCspCore" />
paket add LibCspCore --version 1.0.0
#r "nuget: LibCspCore, 1.0.0"
#:package LibCspCore@1.0.0
#addin nuget:?package=LibCspCore&version=1.0.0
#tool nuget:?package=LibCspCore&version=1.0.0
基于数字病理Csp格式的.net core跨平台快速读取库
Console.WriteLine("========================================");
Console.WriteLine($"CSP 文件测试: {cspFilePath}");
Console.WriteLine("========================================");
if (!File.Exists(cspFilePath))
{
Console.WriteLine($"文件不存在: {cspFilePath}");
return;
}
try
{
using var pool = new CspReaderPool(
fileHandleTimeout: TimeSpan.FromMinutes(5),
cleanupInterval: TimeSpan.FromMinutes(1),
metadataCacheExpiration: TimeSpan.FromHours(1),
maxHandles: 10);
var reader = await pool.GetReaderAsync(cspFilePath);
// 通过 IWSIReaderProxy 接口测试多态调用
IWSIReaderProxy proxy = reader;
IWSIInfo info = proxy.Info;
Console.WriteLine($"文件: {cspFilePath}");
Console.WriteLine($"尺寸: {info.Width} x {info.Height}");
Console.WriteLine($"层数: {info.Layers.Count}");
Console.WriteLine();
// 打印每层信息
for (short l = 0; l < info.Layers.Count; l++)
{
var layer = info.Layers[l];
Console.WriteLine($" Layer {l}: {layer.Width}x{layer.Height}, " +
$"Tiles: {layer.Cols}x{layer.Rows} ({layer.TileWidth}x{layer.TileHeight}), " +
$"Virtual: {layer.IsVirtual}, " +
$"TileCount: {layer.TileOffsets?.Length ?? 0}");
}
Console.WriteLine();
Console.WriteLine("附加图像:");
foreach (var kvp in info.AssociatedImages)
{
var ext = kvp.Value;
Console.WriteLine($" [{kvp.Key}] {ext.FileName}: offset={ext.Offset}, length={ext.Length}, " +
$"{ext.RawWidth}x{ext.RawHeight}, IsRaw={ext.IsRawPixels}");
}
// 测试读取每一层的所有瓦片,输出到文件
string baseOutDir = Path.Combine(Path.GetDirectoryName(cspFilePath) ?? ".", "test_output");
for (short level = 0; level < info.Layers.Count; level++)
{
var targetLayer = info.Layers[level];
Console.WriteLine();
Console.WriteLine($"读取 Layer {level}: {targetLayer.Width}x{targetLayer.Height}, " +
$"Tiles: {targetLayer.Cols}x{targetLayer.Rows}...");
string layerDir = Path.Combine(baseOutDir, level.ToString());
if (!Directory.Exists(layerDir))
Directory.CreateDirectory(layerDir);
int count = 0;
for (int row = 0; row < targetLayer.Rows; row++)
{
for (int col = 0; col < targetLayer.Cols; col++)
{
byte[] tileData = proxy.ReadTileImg(level, row, col);
if (tileData != null && tileData.Length > 0)
{
File.WriteAllBytes(Path.Combine(layerDir, $"{row}-{col}.jpg"), tileData);
}
count++;
}
}
Console.WriteLine($" Layer {level} 完成: 共 {count} 个瓦片, 输出到 {layerDir}");
}
// 测试读取附加图像
Console.WriteLine();
foreach (var kvp in info.AssociatedImages)
{
Console.WriteLine($"读取附加图像 [{kvp.Key}]...");
byte[] imgData = proxy.GetAssociatedImageJpegBytes(kvp.Value);
if (imgData != null && imgData.Length > 0)
{
Console.WriteLine($" 成功: {imgData.Length} 字节");
string outDir = Path.Combine(Path.GetDirectoryName(cspFilePath) ?? ".", "test_output");
Directory.CreateDirectory(outDir);
File.WriteAllBytes(Path.Combine(outDir, $"{kvp.Key}.jpg"), imgData);
Console.WriteLine($" 已保存到: {outDir}\\{kvp.Key}.jpg");
}
else
{
Console.WriteLine(" 读取失败或为空!");
}
}
Console.WriteLine();
Console.WriteLine("测试完成!");
}
catch (Exception ex)
{
Console.WriteLine($"CSP 测试出错: {ex.GetType().Name}: {ex.Message}");
Console.WriteLine(ex.StackTrace);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- libjpeg-turbo-net (>= 2.0.15)
- LibTiffCore (>= 1.2.6)
- Microsoft.Extensions.Caching.Memory (>= 2.1.23)
- SkiaSharp (>= 3.119.0-preview.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.