Example #1
0
mitk::ImageDataItem::ImageDataItem(const mitk::ImageDescriptor::Pointer desc, void *data, bool manageMemory)
  : m_Data((unsigned char*)data), m_ManageMemory(manageMemory), m_VtkImageData(NULL), m_Offset(0), m_IsComplete(false), m_Size(0)
{
  m_PixelType = new mitk::PixelType(desc->GetChannelDescriptor(0).GetPixelType());

  // compute size
  const unsigned int *dimensions = desc->GetDimensions();

  m_Dimension = desc->GetNumberOfDimensions();
  for( unsigned int i=0; i<m_Dimension; i++)
    m_Dimensions[i] = dimensions[i];

  this->ComputeItemSize(m_Dimensions, m_Dimension );

  if(m_Data == NULL)
  {
    m_Data = mitk::MemoryUtilities::AllocateElements<unsigned char>( m_Size );
    m_ManageMemory = true;
  }

  m_ReferenceCountLock.Lock();
  m_ReferenceCount = 0;
  m_ReferenceCountLock.Unlock();

}
Example #2
0
void mitk::Image::Initialize(const mitk::ImageDescriptor::Pointer inDesc)
{
  // store the descriptor
  this->m_ImageDescriptor = inDesc;

  // initialize image
  this->Initialize( inDesc->GetChannelDescriptor(0).GetPixelType(), inDesc->GetNumberOfDimensions(), inDesc->GetDimensions(), 1 );
}