处理scp服务 拆分影像
parent
4945daa0d4
commit
a19ba3c215
|
|
@ -24,6 +24,8 @@ using IRaCIS.Core.Infrastructure;
|
|||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Newtonsoft.Json;
|
||||
using FellowOakDicom.Imaging.Codec;
|
||||
using FellowOakDicom.IO.Buffer;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace IRaCIS.Core.SCP.Service
|
||||
{
|
||||
|
|
@ -237,7 +239,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
}
|
||||
else
|
||||
{
|
||||
Log.Logger.Error($"未找到{g.Key.StudyInstanceUid}的Cmove记录");
|
||||
Log.Logger.Warning($"未找到{g.Key.StudyInstanceUid}的Cmove记录");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,6 +321,7 @@ namespace IRaCIS.Core.SCP.Service
|
|||
|
||||
|
||||
long fileSize = 0;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
|
@ -326,7 +329,61 @@ namespace IRaCIS.Core.SCP.Service
|
|||
{
|
||||
await request.File.SaveAsync(ms);
|
||||
|
||||
#region 1帧拆成多个固定大小的,方便移动端浏览
|
||||
|
||||
// 回到开头,读取 dicom
|
||||
ms.Position = 0;
|
||||
var dicomFile = DicomFile.Open(ms);
|
||||
|
||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||
var syntax = pixelData.Syntax;
|
||||
|
||||
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
||||
int fragmentSize = 20 * 1024;
|
||||
|
||||
if (syntax.IsEncapsulated)
|
||||
{
|
||||
var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
|
||||
|
||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||
{
|
||||
var frameData = pixelData.GetFrame(n); // 获取完整一帧
|
||||
var data = frameData.Data;
|
||||
int offset = 0;
|
||||
|
||||
while (offset < data.Length)
|
||||
{
|
||||
int size = Math.Min(fragmentSize, data.Length - offset);
|
||||
var buffer = new byte[size];
|
||||
Buffer.BlockCopy(data, offset, buffer, 0, size);
|
||||
|
||||
newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
|
||||
offset += size;
|
||||
}
|
||||
}
|
||||
|
||||
// 替换原 PixelData
|
||||
dicomFile.Dataset.AddOrUpdate(newFragments);
|
||||
}
|
||||
|
||||
// 重新保存 dicom 到流
|
||||
ms.SetLength(0);
|
||||
dicomFile.Save(ms);
|
||||
ms.Position = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 本地测试
|
||||
//// --- 保存到本地文件测试 ---
|
||||
//var localPath = @"D:\TestDicom.dcm";
|
||||
//using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write))
|
||||
//{
|
||||
// ms.CopyTo(fs);
|
||||
//}
|
||||
//return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
//irc 从路径最后一截取Guid
|
||||
|
|
|
|||
|
|
@ -13604,7 +13604,7 @@
|
|||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.HospitalGroupService.GetGAUserList">
|
||||
<member name="M:IRaCIS.Core.Application.Service.HospitalGroupService.GetGAUserList(System.Guid)">
|
||||
<summary>
|
||||
GA用户列表
|
||||
</summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue