資源簡介
使用C#編碼進行 醫學影像信息Dicom圖片文件查看
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
using?System.Collections;
using?System.Drawing;
namespace?DicomViewer
{
????class?DicomHandler
????{
????????string?fileName?=?““;
????????Dictionary?tags?=?new?Dictionary();//dicom文件中的標簽
????????BinaryReader?dicomFile;//dicom文件流
????????//文件元信息
????????public?Bitmap?gdiImg;//轉換后的gdi圖像
????????UInt32?fileHeadLen;//文件頭長度
????????long?fileHeadOffset;//文件數據開始位置
????????UInt32?pixDatalen;//像素數據長度
????????long?pixDataOffset?=?0;//像素數據開始位置
????????bool?isLitteEndian?=?true;//是否小字節序(小端在前?、大端在前)
????????bool?isExplicitVR?=?true;//有無VR
????????//像素信息
????????int?colors;//顏色數?RGB為3?黑白為1
????????public?int?windowWith?=?2048?windowCenter?=?2048?/?2;//窗寬窗位
????????int?rows?cols;
????????public?void?readAndShow(TextBox?textBox1)
????????{
????????????if?(fileName?==?string.Empty)
????????????????return;
????????????dicomFile?=?new?BinaryReader(File.OpenRead(fileName));
????????????//跳過128字節導言部分
????????????dicomFile.baseStream.Seek(128?SeekOrigin.Begin);
????????????if?(new?string(dicomFile.ReadChars(4))?!=?“DICM“)
????????????{
????????????????MessageBox.Show(“沒有dicom標識頭,文件格式錯誤“);
????????????????return;
????????????}
????????????tagRead();
????????????IDictionaryEnumerator?enor?=?tags.GetEnumerator();
????????????while?(enor.MoveNext())
????????????{
????????????????if?(enor.Key.ToString().Length?>?9)
????????????????{
????????????????????textBox1.Text?+=?enor.Key.ToString()?+?“\r\n“;
????????????????????textBox1.Text?+=?enor.Value.ToString().Replace(‘\0‘?‘?‘);
????????????????}
????????????????else
????????????????????textBox1.Text?+=?enor.Key.ToString()?+?enor.Value.ToString().Replace(‘\0‘?‘?‘)?+?“\r\n“;
????????????}
????????????dicomFile.Close();
????????}
????????public??DicomHandler(string?_filename)
????????{
????????????fileName?=?_filename;
????????}
????????public?void?saveAs(string?filename)
????????{
????????????switch?(filename.Substring(filename.LastIndexOf(‘.‘)))
????????????{
????????????????case?“.jpg“:
????????????????????gdiImg.Save(filename?System.Drawing.Imaging.ImageFormat.Jpeg);
????????????????????break;
????????????????case?“.bmp“:
????????????????????gdiImg.Save(filename?System.Drawing.Imaging.ImageFormat.Bmp);
????????????????????break;
????????????????case?“.png“:
????????????????????gdiImg.Save(filename?System.Drawing.Imaging.ImageFormat.Png);
????????????????????break;
????????????????default:
????????????????????break;
????????????}
????????}
????????public?bool?getImg(?)//獲取圖像?在圖像數據偏移量已經確定的情況下
????????{
????????????if?(fileName?==?string.Empty)
????????????????return?false;
????????????
????????????int?dataLen?validLen;//數據長度?有效位
????????????int?imgNum;//幀數
????????????rows?=?int.Parse(tags[“00280010“].Substring(5));
????????????cols?=?int.Parse(tags[“00280011“].Substring(5))
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\
?????文件???????17839??2013-01-09?12:10??C#?winform?醫學影像信息Dicom圖片文件查看器\DicomHandler.cs
?????文件????????3793??2013-08-29?20:16??C#?winform?醫學影像信息Dicom圖片文件查看器\DicomViewer.csproj
?????文件?????????911??2012-12-30?23:30??C#?winform?醫學影像信息Dicom圖片文件查看器\DicomViewer.sln
?????文件???????18944??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\DicomViewer.suo
?????文件???????11788??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\Main.Designer.cs
?????文件????????4496??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\Main.cs
?????文件???????14182??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\Main.resx
?????文件?????????909??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\Program.cs
?????目錄???????????0??2013-08-29?12:42??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\
?????文件????????1378??2012-12-27?11:29??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\AssemblyInfo.cs
?????文件????????2872??2012-12-27?11:29??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\Resources.Designer.cs
?????文件????????5612??2012-12-27?11:29??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\Resources.resx
?????文件????????1096??2012-12-27?11:29??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\Settings.Designer.cs
?????文件?????????249??2012-12-27?11:29??C#?winform?醫學影像信息Dicom圖片文件查看器\Properties\Settings.settings
?????文件?????????120??2012-12-27?16:31??C#?winform?醫學影像信息Dicom圖片文件查看器\app.config
?????目錄???????????0??2013-08-29?20:16??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\
?????目錄???????????0??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\
?????文件??????526316??2012-10-30?15:50??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\CT.dcm
?????文件???????28160??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.exe
?????文件?????????120??2012-12-27?16:31??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.exe.config
?????文件???????38400??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.pdb
?????文件???????14328??2013-08-29?20:17??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.vshost.exe
?????文件?????????120??2012-12-27?16:31??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.vshost.exe.config
?????文件?????????490??2009-06-11?05:14??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\DicomViewer.vshost.exe.manifest
?????文件??????526598??2005-11-11?14:46??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\IM-0001-0002.dcm
?????文件???????49664??2013-07-10?21:15??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\Visual?Studio?Tools.exe
?????文件???????93064??1999-06-05?09:18??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\color.dcm
?????文件???????35328??2013-08-29?11:35??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\qqshareUpdate.exe
?????文件???????52224??2013-08-29?12:59??C#?winform?醫學影像信息Dicom圖片文件查看器\bin\Debug\互聯網帳號共享器.exe
?????目錄???????????0??2012-12-30?17:57??C#?winform?醫學影像信息Dicom圖片文件查看器\obj\
............此處省略9個文件信息
- 上一篇:c#課程設計報告很完整的
- 下一篇:C#獲取圖片并保存到本地
評論
共有 條評論