xp_comm_proj/rd_dicom/Papyrus3/PapyDataSetRead3.c
/********************************************************************************/
/*									 	*/
/*	ExtractGroup28Information : Extracts some elements from the group 28 	*/
/*	that will be needed further.						*/
/*	return : standard error message.					*/
/*										*/
/********************************************************************************/
ExtractGroup28Information : Extracts some elements from the group 28
that will be needed further.
return : standard error message.
ExtractGroup28Information : Extracts some elements from the group 28 that will be needed further . return : standard error message .
PapyShort
ExtractGroup28Information (PapyShort inFileNb)
{
  char		thePhotoInterpret [16];
  PapyShort	theErr;
  int		theElemType, theNbIm = 1;
  PapyULong	theNbVal;
  UValue_T	*theValP;
  SElement	*theGroup28P;
  if ((theErr = Papy3GotoGroupNb (inFileNb, 0x0028)) < 0)
    RETURN (theErr); 
  if ((theErr = Papy3GroupRead (inFileNb, &theGroup28P)) < 0)
    RETURN (theErr);
  if (gIsPapyFile [inFileNb] == DICOM10 || gIsPapyFile [inFileNb] == DICOM_NOT10)
  {
    theValP = Papy3GetElement (theGroup28P, papNumberofFramesGr, &theNbVal, &theElemType);
    if (theValP != NULL)
      sscanf (theValP->a, "%d", &theNbIm);
    gArrNbImages [inFileNb] = (PapyShort) theNbIm;
  } 
  gx0028Rows [inFileNb] = theGroup28P [papRowsGr].value->us;
  gx0028Columns [inFileNb] = theGroup28P [papColumnsGr].value->us;
  if (theGroup28P [papImageFormatGr].nb_val > 0L)
    gx0028ImageFormat [inFileNb] = PapyStrDup (theGroup28P [papImageFormatGr].value->a);
  if (theGroup28P [papBitsAllocatedGr].nb_val > 0L)
  {
    gx0028BitsAllocated [inFileNb] = theGroup28P [papBitsAllocatedGr].value->us;
    if (gx0028BitsAllocated [inFileNb] == 24)
      gx0028BitsAllocated [inFileNb] = 8;
  } 
  if (theGroup28P [papBitsStoredGr].nb_val > 0L)
    gx0028BitsStored [inFileNb] = theGroup28P [papBitsStoredGr].value->us;
  theValP = Papy3GetElement (theGroup28P, papPhotometricInterpretationGr, &theNbVal, &theElemType);
  if (theValP != NULL)
    strcpy (thePhotoInterpret, theValP->a);
  else  
    strcpy (thePhotoInterpret, "MONOCHROME2");
  theErr = Papy3GroupFree (&theGroup28P, TRUE);
  if (strcmp (thePhotoInterpret, "MONOCHROME1") == 0) 
    gArrPhotoInterpret [inFileNb] = MONOCHROME1;
  else if (strcmp (thePhotoInterpret, "MONOCHROME2") == 0) 
    gArrPhotoInterpret [inFileNb] = MONOCHROME2;
  else if (strcmp (thePhotoInterpret, "PALETTE COLOR") == 0) 
    gArrPhotoInterpret [inFileNb] = PALETTE;
  else if (strcmp (thePhotoInterpret, "RGB") == 0) 
    gArrPhotoInterpret [inFileNb] = RGB;
  else if (strcmp (thePhotoInterpret, "HSV") == 0) 
    gArrPhotoInterpret [inFileNb] = HSV;
  else if (strcmp (thePhotoInterpret, "ARGB") == 0) 
    gArrPhotoInterpret [inFileNb] = ARGB;
  else if (strcmp (thePhotoInterpret, "CMYK") == 0) 
    gArrPhotoInterpret [inFileNb] = CMYK;
  else if (strcmp (thePhotoInterpret, "YBR_FULL") == 0) 
    gArrPhotoInterpret [inFileNb] = YBR_FULL;
  else if (strcmp (thePhotoInterpret, "YBR_FULL_422") == 0) 
    gArrPhotoInterpret [inFileNb] = YBR_FULL_422;
  else if (strcmp (thePhotoInterpret, "YBR_PARTIAL_422") == 0) 
    gArrPhotoInterpret [inFileNb] = YBR_PARTIAL_422;
  RETURN (papNoError);
}
PapyShort ExtractGroup28Information ( PapyShort inFileNb ) { char thePhotoInterpret [ 16 ] ; PapyShort theErr ; int theElemType , theNbIm = 1 ; PapyULong theNbVal ; UValue_T * theValP ; SElement * theGroup28P ; if ( ( theErr = Papy3GotoGroupNb ( inFileNb , 0x0028 ) ) < 0 ) RETURN ( theErr ) ; if ( ( theErr = Papy3GroupRead ( inFileNb , & theGroup28P ) ) < 0 ) RETURN ( theErr ) ; if ( gIsPapyFile [ inFileNb ] == DICOM10 || gIsPapyFile [ inFileNb ] == DICOM_NOT10 ) { theValP = Papy3GetElement ( theGroup28P , papNumberofFramesGr , & theNbVal , & theElemType ) ; if ( theValP != NULL ) sscanf ( theValP -> a , " " , & theNbIm ) ; gArrNbImages [ inFileNb ] = ( PapyShort ) theNbIm ; } gx0028Rows [ inFileNb ] = theGroup28P [ papRowsGr ] . value -> us ; gx0028Columns [ inFileNb ] = theGroup28P [ papColumnsGr ] . value -> us ; if ( theGroup28P [ papImageFormatGr ] . nb_val > 0L ) gx0028ImageFormat [ inFileNb ] = PapyStrDup ( theGroup28P [ papImageFormatGr ] . value -> a ) ; if ( theGroup28P [ papBitsAllocatedGr ] . nb_val > 0L ) { gx0028BitsAllocated [ inFileNb ] = theGroup28P [ papBitsAllocatedGr ] . value -> us ; if ( gx0028BitsAllocated [ inFileNb ] == 24 ) gx0028BitsAllocated [ inFileNb ] = 8 ; } if ( theGroup28P [ papBitsStoredGr ] . nb_val > 0L ) gx0028BitsStored [ inFileNb ] = theGroup28P [ papBitsStoredGr ] . value -> us ; theValP = Papy3GetElement ( theGroup28P , papPhotometricInterpretationGr , & theNbVal , & theElemType ) ; if ( theValP != NULL ) strcpy ( thePhotoInterpret , theValP -> a ) ; else strcpy ( thePhotoInterpret , " " ) ; theErr = Papy3GroupFree ( & theGroup28P , TRUE ) ; if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = MONOCHROME1 ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = MONOCHROME2 ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = PALETTE ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = RGB ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = HSV ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = ARGB ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = CMYK ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = YBR_FULL ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = YBR_FULL_422 ; else if ( strcmp ( thePhotoInterpret , " " ) == 0 ) gArrPhotoInterpret [ inFileNb ] = YBR_PARTIAL_422 ; RETURN ( papNoError ) ; }
ExtractGroup28Information : Extracts some elements from the group 28
that will be needed further.
ExtractGroup28Information : Extracts some elements from the group 28 that will be needed further .
/* goto group 28 and read it */ /* *** save the value of the needed elements *** */ /* extract number of frames only if DICOM file */ /* if */ /* number of ROWS */ /* number of COLUMNS */ /* the image format */ /* the BITS ALLOCATED */ /* 24 bits images (RGB) should be seen as 8 bits allocated by channel... */ /* if */ /* the BITS STORED */ /* the photometric interpretation */ /* default value */ /* free the group 28 */ /* set the PAPYRUS global var according to the extracted value */