@@ -82,9 +82,35 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 方式一 有的必须在内存中,不能用这种
|
||||
//await using var source = await sourceFactory();
|
||||
//// 如果你是从 stream 打开
|
||||
//var dicomFile = await DicomFile.OpenAsync(source);
|
||||
#endregion
|
||||
|
||||
#region 方式二
|
||||
|
||||
await using var source = await sourceFactory();
|
||||
|
||||
// 【关键修复】将 OSS 流缓冲到 MemoryStream
|
||||
using var bufferedStream = new MemoryStream();
|
||||
|
||||
if (source.CanSeek)
|
||||
{
|
||||
source.Position = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 完全复制到内存流
|
||||
await source.CopyToAsync(bufferedStream);
|
||||
bufferedStream.Position = 0; // 重置位置
|
||||
}
|
||||
|
||||
// 如果你是从 stream 打开
|
||||
var dicomFile = await DicomFile.OpenAsync(source);
|
||||
var dicomFile = await DicomFile.OpenAsync(source.CanSeek ? source : bufferedStream);
|
||||
|
||||
#endregion
|
||||
|
||||
//获取像素是否为封装形式
|
||||
var syntax = dicomFile.Dataset.InternalTransferSyntax;
|
||||
|
||||
Reference in New Issue
Block a user