📄 reconciletiff.cpp
字号:
xmp->SetProperty ( kXMP_NS_EXIF, "NativeDigest", newDigest.c_str() );} // ReconcileUtils::SetExifDigest;// =================================================================================================// =================================================================================================// =================================================================================================// ImportSingleTIFF_Short// ======================static voidImportSingleTIFF_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 binValue = *((XMP_Uns16*)tagInfo.dataPtr); if ( ! nativeEndian ) binValue = Flip2 ( binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Short// =================================================================================================// ImportSingleTIFF_Long// =====================static voidImportSingleTIFF_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 binValue = *((XMP_Uns32*)tagInfo.dataPtr); if ( ! nativeEndian ) binValue = Flip4 ( binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%lu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Long// =================================================================================================// ImportSingleTIFF_Rational// =========================static voidImportSingleTIFF_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; 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->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Rational// =================================================================================================// ImportSingleTIFF_SRational// ==========================static voidImportSingleTIFF_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; 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->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_SRational// =================================================================================================// ImportSingleTIFF_ASCII// ======================static voidImportSingleTIFF_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 bool hasNul = (chPtr[tagInfo.dataLen-1] == 0); const bool isUTF8 = ReconcileUtils::IsUTF8 ( chPtr, tagInfo.dataLen ); if ( isUTF8 && hasNul ) { xmp->SetProperty ( xmpNS, xmpProp, chPtr ); } else { std::string strValue; if ( isUTF8 ) { strValue.assign ( chPtr, tagInfo.dataLen ); } else { ReconcileUtils::LocalToUTF8 ( chPtr, tagInfo.dataLen, &strValue ); } xmp->SetProperty ( xmpNS, xmpProp, strValue.c_str() ); } } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_ASCII// =================================================================================================// ImportSingleTIFF_Byte// =====================static voidImportSingleTIFF_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 binValue = *((XMP_Uns8*)tagInfo.dataPtr); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hu", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Byte// =================================================================================================// ImportSingleTIFF_SByte// ======================static voidImportSingleTIFF_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 binValue = *((XMP_Int8*)tagInfo.dataPtr); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hd", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_SByte// =================================================================================================// ImportSingleTIFF_SShort// =======================static voidImportSingleTIFF_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 binValue = *((XMP_Int16*)tagInfo.dataPtr); if ( ! nativeEndian ) Flip2 ( &binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%hd", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_SShort// =================================================================================================// ImportSingleTIFF_SLong// ======================static voidImportSingleTIFF_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 binValue = *((XMP_Int32*)tagInfo.dataPtr); if ( ! nativeEndian ) Flip4 ( &binValue ); char strValue[20]; snprintf ( strValue, sizeof(strValue), "%ld", binValue ); // AUDIT: Using sizeof(strValue) is safe. xmp->SetProperty ( xmpNS, xmpProp, strValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_SLong// =================================================================================================// ImportSingleTIFF_Float// ======================static voidImportSingleTIFF_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 binValue = *((float*)tagInfo.dataPtr); if ( ! nativeEndian ) Flip4 ( &binValue ); xmp->SetProperty_Float ( xmpNS, xmpProp, binValue ); } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Float// =================================================================================================// ImportSingleTIFF_Double// =======================static voidImportSingleTIFF_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 binValue = *((double*)tagInfo.dataPtr); if ( ! nativeEndian ) Flip8 ( &binValue ); xmp->SetProperty_Float ( xmpNS, xmpProp, binValue ); // ! Yes, SetProperty_Float. } catch ( ... ) { // Do nothing, let other imports proceed. // ? Notify client? }} // ImportSingleTIFF_Double// =================================================================================================// ImportSingleTIFF// ================static voidImportSingleTIFF ( const TIFF_Manager::TagInfo & tagInfo, const bool nativeEndian, SXMPMeta * xmp, const char * xmpNS, const char * xmpProp ){ // We've got a tag to map to XMP, decide how based on actual type and the expected count. Using // the actual type eliminates a ShortOrLong case. Using the expected count is needed to know // whether to create an XMP array. The actual count for an array could be 1. Put the most // common cases first for better iCache utilization. switch ( tagInfo.type ) { case kTIFF_ShortType : ImportSingleTIFF_Short ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_LongType : ImportSingleTIFF_Long ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_RationalType : ImportSingleTIFF_Rational ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_SRationalType : ImportSingleTIFF_SRational ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_ASCIIType : ImportSingleTIFF_ASCII ( tagInfo, xmp, xmpNS, xmpProp ); break; case kTIFF_ByteType : ImportSingleTIFF_Byte ( tagInfo, xmp, xmpNS, xmpProp ); break; case kTIFF_SByteType : ImportSingleTIFF_SByte ( tagInfo, xmp, xmpNS, xmpProp ); break; case kTIFF_SShortType : ImportSingleTIFF_SShort ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_SLongType : ImportSingleTIFF_SLong ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_FloatType : ImportSingleTIFF_Float ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; case kTIFF_DoubleType : ImportSingleTIFF_Double ( tagInfo, nativeEndian, xmp, xmpNS, xmpProp ); break; }} // ImportSingleTIFF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -