Logo Search packages:      
Sourcecode: gdcm version File versions

unsigned long gdcm::Pixmap::GetBufferLength (  )  const

Return the length of the image after decompression WARNING for palette color: It will NOT take into account the Palette Color thus you need to multiply this length by 3 if the image is RGB for instance.

Definition at line 206 of file gdcmPixmap.cxx.

References gdcm::PixelFormat::GetPixelSize(), and gdcm::PixelFormat::GetSamplesPerPixel().

Referenced by gdcm::ImageApplyLookupTable::Apply(), gdcm::ImageChangePlanarConfiguration::Change(), itk::GDCMImageIO2::Read(), gdcm::SplitMosaicFilter::Split(), and itk::GDCMImageIO2::Write().

{
  assert( NumberOfDimensions );
  //assert( NumberOfDimensions == Dimensions.size() );
  if( NumberOfDimensions != Dimensions.size() )
    {
    assert( Dimensions[2] == 1 );
    }
  unsigned long len = 0;
  unsigned int mul = 1;
  // First multiply the dimensions:
  std::vector<unsigned int>::const_iterator it = Dimensions.begin();
  for(; it != Dimensions.end(); ++it)
    {
    mul *= *it;
    }
  // Multiply by the pixel size:
  // Special handling of packed format:
  if( PF == PixelFormat::UINT12 )
    {
    assert( PF.GetSamplesPerPixel() == 1 );
    unsigned int save = mul;
    save *= 12;
    save /= 8;
    assert( save * 8 / 12 == mul );
    mul = save;
    }
  else
    {
    mul *= PF.GetPixelSize();
    }
  len = mul;

  assert( len != 0 );
  return len;
}


Generated by  Doxygen 1.6.0   Back to index