我一直在使用 ClearCanvas 在 C# 中显示 DICOM 图像,开发人员 Steve 帮助我阅读图像的标签。然而,我已经在这个项目上工作了将近两个星期,并试图显示图像。我已经尝试并在 Steve 的帮助下添加了代码,但我无法显示 DICOM 图像。也许我正在做的是不正确的,有人可以看看代码,并希望告诉我什么是错的,或者是他们显示它的另一种方式。我一直试图让这个项目在 C# 中工作,希望能够转换为 Visual Basic。我再次获得相同的错误。代码贴在下面。
enter
string filename = @"C:\Users\Don jar\Pictures\Xray pics\fluro.dcm";
DicomFile dicomFile = new DicomFile(filename);
dicomFile.Load(DicomReadOptions.Default);
foreach (DicomAttribute attribute in dicomFile.DataSet)
{
Console.WriteLine("Tag: {0}, Value: {1}", attribute.Tag.Name, attribute.ToString());
}
int bitsPerPixel = dicomFile.DataSet.GetAttribute(DicomTags.BitsStored).GetInt32(0, 0);
int width = dicomFile.DataSet.GetAttribute(DicomTags.Columns).GetInt32(0, 0);
int height = dicomFile.DataSet.GetAttribute(DicomTags.Rows).GetInt32(0, 0);
int stride = width * 2;
byte[] bitmapBuffer = (byte[])dicomFile.DataSet.GetAttribute(DicomTags.PixelData).Values;
BitmapSource bitmapSource = BitmapImage.Create(width, height, 96, 96, System.Windows.Media.PixelFormats.Gray16, null, bitmapBuffer, stride);
pictureBox1.Image = bitmapSource; code here
显示的错误在最后一行 pictureBox1.Image = bitmapSource; 错误是
错误 1“System.Windows.Forms.PictureBox”不包含“Source”的定义,并且找不到接受“System.Windows.Forms.PictureBox”类型的第一个参数的扩展方法“Source”(您是否缺少使用指令还是程序集引用?) C:\Users\Don jar\Documents\Visual Studio 2010\Projects\DICOMCA\DICOMCA\Form1.c
第二个错误是错误 2 无法将类型 'System.Windows.Media.Imaging.BitmapSource' 隐式转换为 'System.Drawing.Image' C:\Users\Don jar\Documents\Visual Studio 2010\Projects\DICOMCA\DICOMCA\Form1 .cs 62 33 迪科马