simple overlay example

All other questions regarding DICOMscope

Moderator: Moderator Team

Post Reply
Message
Author
nicola.denisco
Posts: 1
Joined: Thu, 2008-02-14, 11:36

simple overlay example

#1 Post by nicola.denisco »

I try to write a code to generate overlay in
presentation state and it not work.

Is possible to post a simple example?
thanks a lot.

it's my test code (it don't run):

Code: Select all

int main(int argc, char *argv[])
{
  DcmFileFormat infile;
  DcmFileFormat outfile;
  if (infile.loadFile("/tmp/test.dcm").good())
  {
    printf("Caricata immagine dicom.\n");

    DVPresentationState pstate; // presentation state handler
    if (pstate.createFromImage(*infile.getDataset()).good())
    {
      pstate.addGraphicLayer("pippo", "prova pippo"); 
      size_t idl = pstate.getGraphicLayerIndex("pippo");
 
      printf("Numero layer %d idl=%d.\n", pstate.getNumberOfGraphicLayers(), idl);

      pstate.renderPixelData();

      // disegna nel ps
      DVPSTextObject *to = pstate.addTextObject(idl);
      if(to == NULL)
      {
        puts("niente DVPSTextObject");
      }
      else
      {
        to->setAnchorPoint(100.0, 100.0, DVPSA_pixels, true);
        to->setText("Hello World!");
      }

      // creates a new graphic object on the given layer.
      DVPSGraphicObject *go = pstate.addGraphicObject(idl);
      if(to == NULL)
      {
        puts("niente DVPSGraphicObject");
      }
      else
      {
      }

      // serialize presentation state into DICOM data set structure
      if (pstate.write(*outfile.getDataset(), OFFalse).good())
      {
        // and write to file
        outfile.saveFile("/tmp/gsps.dcm", EXS_LittleEndianExplicit);      
      }
    }
  }

  return 0;
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest