| 707 | } |
| 708 | |
| 709 | void ItkImageIO::Write() |
| 710 | { |
| 711 | const auto *image = dynamic_cast<const mitk::Image *>(this->GetInput()); |
| 712 | |
| 713 | if (image == nullptr) |
| 714 | { |
| 715 | mitkThrow() << "Cannot write non-image data"; |
| 716 | } |
| 717 | |
| 718 | PreparImageIOToWriteImage(m_ImageIO, image); |
| 719 | |
| 720 | LocalFile localFile(this); |
| 721 | const std::string path = localFile.GetFileName(); |
| 722 | |
| 723 | MITK_INFO << "Writing image: " << path << std::endl; |
| 724 | |
| 725 | try |
| 726 | { |
| 727 | // Handle properties |
| 728 | SavePropertyListAsMetaData(m_ImageIO->GetMetaDataDictionary(), image->GetPropertyList(), this->GetMimeType()->GetName()); |
| 729 | // Handle UID |
| 730 | itk::EncapsulateMetaData<std::string>(m_ImageIO->GetMetaDataDictionary(), PROPERTY_KEY_UID, image->GetUID()); |
| 731 | |
| 732 | // use compression if available |
| 733 | m_ImageIO->UseCompressionOn(); |
| 734 | m_ImageIO->SetFileName(path); |
| 735 | |
| 736 | ImageReadAccessor imageAccess(image); |
| 737 | LocaleSwitch localeSwitch2("C"); |
| 738 | m_ImageIO->Write(imageAccess.GetData()); |
| 739 | } |
| 740 | catch (const std::exception &e) |
| 741 | { |
| 742 | mitkThrow() << e.what(); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | AbstractFileIO::ConfidenceLevel ItkImageIO::GetWriterConfidenceLevel() const |
| 747 | { |