0

ClearCanvas を使用して C# で DICOM 画像を表示する作業を行ってきました。開発者の Steve は、画像のタグを読み取るのを手伝ってくれました。しかし、私はこのプロジェクトに取り組み、画像を表示しようとして、ほぼ2週間立ち往生しています。スティーブが助けてくれたものにコードを追加しようとしましたが、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 番目のエラーはエラー 2 型 'System.Windows.Media.Imaging.BitmapSource' を 'System.Drawing.Image' に暗黙的に変換できません C:\Users\Don jar\Documents\Visual Studio 2010\Projects\DICOMCA\DICOMCA\Form1 .cs 62 33 DICOMCA

4

1 に答える 1

0

エラーが示すように、BitmapSource は System.Windows.Media.Imaging.BitmapSource 画像、つまり WPF 画像です。
あなたの pictureBox1 オブジェクトは System.Windows.Forms.PictureBox オブジェクトです。
これら 2 つのことは互換性がありません。Windows フォームの PictureBox に WPF イメージを表示することはできません。

表示するには、BitmapSource を通常の System.Drawing.Bitmap に変換する必要がありますが、幸いなことに、これを行うには複数の方法がありますが、最適なオプションの種類は画像のピクセル形式によって異なります。
BitmapSource を Bitmap に変換する
方法 BitmapSource と Bitmap の間で変換する良い方法はありますか?

その2番目のリンクの答えは、より高速な方法です。

于 2013-08-02T09:18:58.433 に答える