Here it is in python:
r = vtkBMPReader()
r.SetFileName( 'test1.bmp' )
w = vtkGDCMImageWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.dcm' )
w.Write()
If your input BMP uses lookup table, you can simply pass it:
r = vtkBMPReader()
r.SetFileName( 'test1.bmp' )
r.Allow8BitBMPOn()
r.Update()
r.GetOutput().GetPointData().GetScalars().SetLookupTable( r.GetLookupTable() )
w = vtkGDCMImageWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.dcm' )
w.SetImageFormat( VTK_LOOKUP_TABLE );
w.Write()
And the opposite (DICOM -> BMP):
r = vtkGDCMImageReader()
r.SetFileName( 'test1.dcm' )
w = vtkBMPWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.bmp' )
w.Write()
Of course you can do it from the command line, simply use gdcm2vtk:
$ gdcm2vtk input.bmp output.dcm
or
$ gdcm2vtk