LibCspCore 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LibCspCore --version 1.0.0
                    
NuGet\Install-Package LibCspCore -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LibCspCore" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibCspCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="LibCspCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LibCspCore --version 1.0.0
                    
#r "nuget: LibCspCore, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LibCspCore@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LibCspCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=LibCspCore&version=1.0.0
                    
Install as a Cake Tool

基于数字病理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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 59 7/1/2026
1.0.2 68 6/29/2026
1.0.1 62 6/29/2026
1.0.0 69 6/25/2026