LIB3MFMETHODIMP CCOMModelTexture2D::WriteToFile(_In_z_ LPCWSTR pwszFilename) { try { if (pwszFilename == nullptr) throw CNMRException(NMR_ERROR_INVALIDPOINTER); CModelTexture2DResource * pTextureResource = getTexture2D(); __NMRASSERT(pTextureResource); PImportStream pTextureStream = pTextureResource->getTextureStream(); if (pTextureStream.get() != nullptr) { pTextureStream->writeToFile(pwszFilename); } else { throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); } return handleSuccess(); } catch (CNMRException & Exception) { return handleNMRException(&Exception); } catch (...) { return handleGenericException(); } }
LIB3MFMETHODIMP CCOMModelTexture2D::WriteToFileUTF8(_In_z_ LPCSTR pszFilename) { try { if (pszFilename == nullptr) throw CNMRException(NMR_ERROR_INVALIDPOINTER); CModelTexture2DResource * pTextureResource = getTexture2D(); __NMRASSERT(pTextureResource); PImportStream pTextureAttachment = pTextureResource->getTextureStream(); if (pTextureAttachment.get() != nullptr) { std::string sUTF8FileName(pszFilename); std::wstring sUTF16FileName = fnUTF8toUTF16(sUTF8FileName); pTextureAttachment->writeToFile(sUTF16FileName.c_str()); } else { throw CNMRException(NMR_ERROR_NOTEXTURESTREAM); } return handleSuccess(); } catch (CNMRException & Exception) { return handleNMRException(&Exception); } catch (...) { return handleGenericException(); } }