The com version of DicomObjects supports Dicom encoded Mpeg2,which provides a means of displaying these image to a DicomViewer control. DicomObjects achieves Mpeg2 support by using the Directshow architecture to decode the mpeg data, whether it be a dicom encoded Mpeg or a raw mpeg file. Remember to use the Video version of DicomObjects i.e the version that has a version number ending with .5. This video version of DicomObjects is available for download from the Medical Connections website.
How to display Dicom encoded Mpeg2 files in a DicomViewer
In VB.NET use the following code
Dim FilePath as String FilePath = "c:\MyDicomMpg" DicomViewer.Images.ReadFile(FilePath) DicomViewer.CurrentImage.CineMode = doCineMode.doCineRepeat
How to Import and display Mpeg2 Files
Mpeg2 Files can be imported using the existing FileImport method, use DSHOW as the type parameter.
Dim Image As New DicomImage Dim FilePath as String FilePath = "c:\MyMpg" Image.FileImport(FilePath, "DSHOW") DicomViewer.Images.Add(Image) DicomViewer.CurrentImage.CineMode = doCineMode.doCineDirectShow
doCineRepeat or other modes can be used, and then allow full windowing, labels etc., but:
- They are not as efficient (and quick) as doCineDirectShow
- They do not provide the associated audio
How to render Dicom encoded Mpeg2 files to an external window
Dim g As New DicomGlobal Dim objFilter As IFilter Dim pin As IPinInfo Dim v as IVideoWindow Dim image As DicomImage Dim filter As IFilterInfo g_objMc = New FilgraphManager ' create the new filter graph image = g.ReadFile(appbase & "mpg1.dcm") image1.AddDirectShowSource(g_objMc) For Each objFilter In g_objMc.FilterCollection For Each pin In objFilter.Pins pin.Render() Next Next g_objMc.Run()
How to render Dicom encoded Mpeg2 Files to a PictureBox control
This routine is similar to rendering to external window except the the PictureBox control is tied to the IVideoWindow object.
Dim g As New DicomGlobal Dim objFilter As IFilterInfo Dim pin As IPinInfo Dim v As IVideoWindow Dim image1 As DicomImage Dim filter As IFilterInfo g_objMc = New FilgraphManager ' create the new filter graph image1 = g.ReadFile(appbase & "mpg1.dcm") image1.AddDirectShowSource(g_objMc) For Each objFilter In g_objMc.FilterCollection For Each pin In objFilter.Pins pin.Render() Next Next v = g_objMc v.Owner = PictureBox1.Handle.ToInt32 v.SetWindowPosition(0, 0, PictureBox1.Width, PictureBox1.Height) 'Tie the PictureBox to the IVideoWindow v.WindowStyle = &H44000000 g_objMc.Run()
MPEG Importing Issues
Wrong Transfer Syntax when importing other MPEG formats
Since only MEPG-2 is supported in DICOM, errors may occur when importing other MPEG formats, like MPEG-1 and MPEG-4. One typical example is that the ReceivedSyntax of the imported MPEG gets a different value other than the proper DICOM MPGE2 transfer syntax - "1.2.840.10008.1.2.4.100".
Rename any MPEG1 file to "MPEG_1.mpg" and do as shown below, wrong transfer syntax will be prompted up in the message box.
Dim im As New DicomImage im.FileImport "c:\MPEG_1.mpg", "DSHOW" ' ' import that MPEG1 file MsgBox im.ReceivedSyntax ' ' Wrong Transfer Syntax Will be Prompted in the Message Box