MCPcopy Create free account
hub / github.com/MITK/MITK / SetImportChannel

Method SetImportChannel

Modules/Core/src/DataManagement/mitkImage.cpp:706–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704}
705
706bool mitk::Image::SetImportChannel(void *data, int n, ImportMemoryManagementType importMemoryManagement)
707{
708 if (IsValidChannel(n) == false)
709 return false;
710
711 // channel descriptor
712
713 const size_t ptypeSize = this->m_ImageDescriptor->GetChannelTypeById(n).GetSize();
714
715 ImageDataItemPointer ch;
716 if (IsChannelSet(n))
717 {
718 ch = GetChannelData(n, data, importMemoryManagement);
719 if (ch->GetManageMemory() == false)
720 {
721 ch = AllocateChannelData(n, data, importMemoryManagement);
722 if (ch.GetPointer() == nullptr)
723 return false;
724 }
725 if (ch->GetData() != data)
726 std::memcpy(ch->GetData(), data, m_OffsetTable[4] * (ptypeSize));
727 ch->Modified();
728 ch->SetComplete(true);
729 // we have changed the data: call Modified()!
730 Modified();
731 }
732 else
733 {
734 ch = AllocateChannelData(n, data, importMemoryManagement);
735 if (ch.GetPointer() == nullptr)
736 return false;
737 if (ch->GetData() != data)
738 std::memcpy(ch->GetData(), data, m_OffsetTable[4] * (ptypeSize));
739 ch->SetComplete(true);
740
741 this->m_ImageDescriptor->GetChannelDescriptor(n).SetData(ch->GetData());
742 // we just added a missing Channel, which is not regarded as modification.
743 // Therefore, we do not call Modified()!
744 }
745 return true;
746}
747
748void mitk::Image::Initialize()
749{

Callers 6

ScalarToRGBAMethod · 0.80
ScalarAndBinaryToRGBAMethod · 0.80
CombineRGBAImageMethod · 0.80
mitkImageTestFunction · 0.80

Calls 8

ModifiedFunction · 0.85
GetChannelTypeByIdMethod · 0.80
GetPointerMethod · 0.80
GetChannelDescriptorMethod · 0.80
GetSizeMethod · 0.45
GetDataMethod · 0.45
ModifiedMethod · 0.45
SetDataMethod · 0.45

Tested by 1

mitkImageTestFunction · 0.64