版主你好,在V20的HTML5 Medical Viewer这个例子中 ObjectRetrieveAddin.cs 这个文件中有一个方法GetImageTile 用来给前端返回一个png图片的流。我想问下现在这个方法的入参是一个本地磁盘上的dicom文件。 我这边有个需求是有个网络上的dicom流文件,有什么办法直接从dicom流文件中解析获取到png图片的流给前端用来显示,这个dicom流文件不需要保存到本地磁盘上
附上SDK中 GetImageTile 方法如下:
public Stream GetImageTile(string sopInstanceUID, int frameNumber, LeadRect tile, int xResolution, int yResolution, Boolean wldata, string userData, out string mime)
{
mime = SupportedMimeTypes.PNG;
//GetReferencedFile already handles external storage
var referencedFile = GetReferencedFile(new ObjectUID() { SOPInstanceUID = sopInstanceUID});
//var referencedFile = "G:\\images\\DX0002.dcm";
if (!string.IsNullOrEmpty(referencedFile))
{
using (var dicomSourceProxy = new DicomSourceProxy(DataCache))
{
var query = new ViewImageQuery() { FileName = referencedFile, FrameNumber = frameNumber + 1, Tile = tile, Resolution = LeadSize.Create(xResolution, yResolution) };
//processing?
{
var specialFunctions = GetUserFunctions(userData);
var specialFunction = (from u in specialFunctions
where u.Name == "Perio" || u.Name == "Dentin" || u.Name == "Endo"
select u).FirstOrDefault();
if (specialFunction != null)
{
query.PostLoadAction = (image) => { ProcessSpecialFunction(image, specialFunction); };
query.PostLoadActionName = specialFunction.Name;//may add parameters here so to cache different ones
}
}
try
{
var result = dicomSourceProxy.Load(query);
{
if (result.Raw != null)
{
mime = result.RawMimeType;
return result.Raw;//return same stream, no dispose off of the result
}
var output = new byte[0];
if (null != result.AutoScaleData && !result.AutoScaleData.IsEmpty)
{
output = SerializeAutoScale(result.AutoScaleData.AutoScaleIntercept, result.AutoScaleData.AutoScaleSlope, result.Image);
}
var imageStream = new MemoryStream();
if (!wldata)
{
ApplyImageProcessing(result.Image, userData);
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Options.Jpeg.Save.QualityFactor = 2;
codecs.Save(result.Image, imageStream, RasterImageFormat.Jpeg, 0);
imageStream.Position = 0;
}
}
else
{
GetImageBufferAsPNG(result.Image, output, imageStream);
}
result.Dispose();//done with
return imageStream;
}
}
catch
{
//ignored
}
}
}
return new MemoryStream();
}
|
|