Exemplo n.º 1
0
    // Create a 256 x 256 Secondary Capture Image Storage
    static private void CreateSmallDICOM(string fileName)
    {
        using (var writer = new gdcm.PixmapWriter())
        {
            gdcm.Pixmap img = writer.GetImage();
            img.SetNumberOfDimensions(3);
            img.SetDimension(0, 512);
            img.SetDimension(1, 512);
            img.SetDimension(2, 2); // fake a 3d volume
            PhotometricInterpretation pi = new PhotometricInterpretation(PhotometricInterpretation.PIType.MONOCHROME2);
            img.SetPhotometricInterpretation(pi);
            gdcm.DataElement pixeldata = new gdcm.DataElement(new gdcm.Tag(0x7fe0, 0x0010));
            byte[]           buffer    = new byte[512 * 512 * 2];
            pixeldata.SetByteValue(buffer, new gdcm.VL((uint)buffer.Length));
            img.SetDataElement(pixeldata);

            gdcm.File        file         = writer.GetFile();
            gdcm.DataSet     ds           = file.GetDataSet();
            gdcm.DataElement ms           = new gdcm.DataElement(new gdcm.Tag(0x0008, 0x0016));
            string           mediastorage = "1.2.840.10008.5.1.4.1.1.7.2"; // Multi-frame Grayscale Byte Secondary Capture Image Storage
            byte[]           val          = StrToByteArray(mediastorage);
            ms.SetByteValue(val, new gdcm.VL((uint)val.Length));
            ds.Insert(ms);

            writer.SetFileName(fileName);
            writer.Write();
        }
    }
Exemplo n.º 2
0
  // Create a 256 x 256 Secondary Capture Image Storage
  static private void CreateSmallDICOM(string fileName)
    {
    using( var writer = new gdcm.PixmapWriter() )
      {
      gdcm.Pixmap img = writer.GetImage();
      img.SetNumberOfDimensions( 3 );
      img.SetDimension(0, 512 );
      img.SetDimension(1, 512 );
      img.SetDimension(2, 2 ); // fake a 3d volume
      PhotometricInterpretation pi = new PhotometricInterpretation( PhotometricInterpretation.PIType.MONOCHROME2 );
      img.SetPhotometricInterpretation( pi );
      gdcm.DataElement pixeldata = new gdcm.DataElement( new gdcm.Tag(0x7fe0,0x0010) );
      byte[] buffer = new byte[ 512 * 512 * 2 ];
      pixeldata.SetByteValue( buffer, new gdcm.VL((uint)buffer.Length) );
      img.SetDataElement( pixeldata );

      gdcm.File file = writer.GetFile();
      gdcm.DataSet ds = file.GetDataSet();
      gdcm.DataElement ms = new gdcm.DataElement(new gdcm.Tag(0x0008,0x0016));
      string mediastorage = "1.2.840.10008.5.1.4.1.1.7.2"; // Multi-frame Grayscale Byte Secondary Capture Image Storage
      byte[] val = StrToByteArray(mediastorage);
      ms.SetByteValue( val, new gdcm.VL( (uint)val.Length) );
      ds.Insert( ms );

      writer.SetFileName( fileName );
      writer.Write();
      }
    }