| 679 | } |
| 680 | |
| 681 | void mitk::Image::AllocateZeroedVolume(int t, int n) |
| 682 | { |
| 683 | if (!this->IsInitialized()) |
| 684 | mitkThrow() << "AllocateZeroedVolume: image is not initialized. " |
| 685 | << "Call Initialize() first to set pixel type and dimensions."; |
| 686 | |
| 687 | if (m_Dimension == 0 || m_Dimension > 3) |
| 688 | mitkThrow() << "AllocateZeroedVolume: unsupported image dimension " << m_Dimension |
| 689 | << " (expected 1 to 3)."; |
| 690 | |
| 691 | if (this->IsVolumeSet(t, n)) |
| 692 | mitkThrow() << "AllocateZeroedVolume: volume at t=" << t << ", n=" << n |
| 693 | << " is already allocated."; |
| 694 | |
| 695 | size_t numBytes = this->GetPixelType().GetSize(); |
| 696 | |
| 697 | for (unsigned int i = 0; i < m_Dimension; ++i) |
| 698 | numBytes *= m_Dimensions[i]; |
| 699 | |
| 700 | auto data = new unsigned char[numBytes]; |
| 701 | std::memset(data, 0, numBytes); |
| 702 | |
| 703 | this->SetImportVolume(data, t, n, ManageMemory); |
| 704 | } |
| 705 | |
| 706 | bool mitk::Image::SetImportChannel(void *data, int n, ImportMemoryManagementType importMemoryManagement) |
| 707 | { |