📄 reconciletiff.cpp
字号:
// =================================================================================================// =================================================================================================// =================================================================================================// ImportArrayTIFF_Short// =====================static voidImportArrayTIFF_Short ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Uns16 * binPtr = (XMP_Uns16*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Uns16 binValue = *binPtr; if ( ! nativeEndian ) binValue = Flip2 ( binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_Short// =================================================================================================// ImportArrayTIFF_Long// ====================static voidImportArrayTIFF_Long ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Uns32 * binPtr = (XMP_Uns32*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Uns32 binValue = *binPtr; if ( ! nativeEndian ) binValue = Flip4 ( binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%lu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_Long// =================================================================================================// ImportArrayTIFF_Rational// ========================static voidImportArrayTIFF_Rational ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Uns32 * binPtr = (XMP_Uns32*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, binPtr += 2 ) { XMP_Uns32 binNum = binPtr[0]; XMP_Uns32 binDenom = binPtr[1]; if ( ! nativeEndian ) { binNum = Flip4 ( binNum ); binDenom = Flip4 ( binDenom ); } char strValue[40]; snprintf ( strValue, sizeof(strValue), "%lu/%lu", binNum, binDenom ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_Rational// =================================================================================================// ImportArrayTIFF_SRational// =========================static voidImportArrayTIFF_SRational ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Int32 * binPtr = (XMP_Int32*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, binPtr += 2 ) { XMP_Int32 binNum = binPtr[0]; XMP_Int32 binDenom = binPtr[1]; if ( ! nativeEndian ) { Flip4 ( &binNum ); Flip4 ( &binDenom ); } char strValue[40]; snprintf ( strValue, sizeof(strValue), "%ld/%ld", binNum, binDenom ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_SRational// =================================================================================================// ImportArrayTIFF_ASCII// =====================static voidImportArrayTIFF_ASCII ( const TIFF_Manager::TagInfo & tagInfo, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. const char * chPtr = (const char *)tagInfo.dataPtr; const char * chEnd = chPtr + tagInfo.dataLen; const bool hasNul = (chPtr[tagInfo.dataLen-1] == 0); const bool isUTF8 = ReconcileUtils::IsUTF8 ( chPtr, tagInfo.dataLen ); std::string strValue; if ( (! isUTF8) || (! hasNul) ) { if ( isUTF8 ) { strValue.assign ( chPtr, tagInfo.dataLen ); } else { ReconcileUtils::LocalToUTF8 ( chPtr, tagInfo.dataLen, &strValue ); } chPtr = strValue.c_str(); chEnd = chPtr + strValue.size(); } for ( ; chPtr < chEnd; chPtr += (strlen(chPtr) + 1) ) { xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, chPtr ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_ASCII// =================================================================================================// ImportArrayTIFF_Byte// ====================static voidImportArrayTIFF_Byte ( const TIFF_Manager::TagInfo & tagInfo, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Uns8 * binPtr = (XMP_Uns8*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Uns8 binValue = *binPtr; char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_Byte// =================================================================================================// ImportArrayTIFF_SByte// =====================static voidImportArrayTIFF_SByte ( const TIFF_Manager::TagInfo & tagInfo, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Int8 * binPtr = (XMP_Int8*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Int8 binValue = *binPtr; char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hd", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_SByte// =================================================================================================// ImportArrayTIFF_SShort// ======================static voidImportArrayTIFF_SShort ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Int16 * binPtr = (XMP_Int16*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Int16 binValue = *binPtr; if ( ! nativeEndian ) Flip2 ( &binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hd", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_SShort// =================================================================================================// ImportArrayTIFF_SLong// =====================static voidImportArrayTIFF_SLong ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. XMP_Int32 * binPtr = (XMP_Int32*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { XMP_Int32 binValue = *binPtr; if ( ! nativeEndian ) Flip4 ( &binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%ld", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_SLong// =================================================================================================// ImportArrayTIFF_Float// =====================static voidImportArrayTIFF_Float ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. float * binPtr = (float*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { float binValue = *binPtr; if ( ! nativeEndian ) Flip4 ( &binValue ); std::string strValue; SXMPUtils::ConvertFromFloat ( binValue, "", &strValue ); xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue.c_str() ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportArrayTIFF_Float// =================================================================================================// ImportArrayTIFF_Double// ======================static voidImportArrayTIFF_Double ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ try { // Don't let errors with one stop the others. double * binPtr = (double*)tagInfo.dataPtr; for ( size_t i = 0; i < tagInfo.count; ++i, ++binPtr ) { double binValue = *binPtr; if ( ! nativeEndian ) Flip8 ( &binValue ); std::string strValue; SXMPUtils::ConvertFromFloat ( binValue, "", &strValue ); // ! Yes, ConvertFromFloat. xmp->AppendArrayItem ( xmpNS, xmpProp, kXMP_PropArrayIsOrdered, strValue.c_str() ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -