I have been working in displaying a DICOM image in C# with ClearCanvas, the developer Steve aided me in reading in the tags for the image. However, I have been stuck for almost two weeks working on this project of and on trying to display the image. I have tried and added code to what Steve helped with and yet I am unable to display the DICOM image. Maybe what i'm doing is incorrect, can someone take a look at the code and hopefully tell me what is wrong or is their an alternative way to display it. I have been trying to get this project to work in C# with hopefully being able to convert to Visual basic. I am obtaining the same error over again. The code is posted below.
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
The error being displayed is on the last line pictureBox1.Image = bitmapSource; and the the error is
Error 1 'System.Windows.Forms.PictureBox' does not contain a definition for 'Source' and no extension method 'Source' accepting a first argument of type 'System.Windows.Forms.PictureBox' could be found (are you missing a using directive or an assembly reference?) C:\Users\Don jar\Documents\Visual Studio 2010\Projects\DICOMCA\DICOMCA\Form1.c
The second error is Error 2 Cannot implicitly convert type 'System.Windows.Media.Imaging.BitmapSource' to 'System.Drawing.Image' C:\Users\Don jar\Documents\Visual Studio 2010\Projects\DICOMCA\DICOMCA\Form1.cs 62 33 DICOMCA