| 906 | } |
| 907 | |
| 908 | void CrwMap::encodeArray(const Image& image, const CrwMapping* pCrwMapping, CiffHeader* pHead) { |
| 909 | auto ifdId = [=] { |
| 910 | switch (pCrwMapping->tag_) { |
| 911 | case 0x0001: |
| 912 | return IfdId::canonCsId; |
| 913 | case 0x0004: |
| 914 | return IfdId::canonSiId; |
| 915 | case 0x000f: |
| 916 | return IfdId::canonCfId; |
| 917 | case 0x0012: |
| 918 | return IfdId::canonPiId; |
| 919 | } |
| 920 | return IfdId::ifdIdNotSet; |
| 921 | }(); |
| 922 | DataBuf buf = packIfdId(image.exifData(), ifdId, pHead->byteOrder()); |
| 923 | if (buf.empty()) { |
| 924 | // Try the undecoded tag |
| 925 | encodeBasic(image, pCrwMapping, pHead); |
| 926 | } |
| 927 | if (!buf.empty()) { |
| 928 | // Write the number of shorts to the beginning of buf |
| 929 | buf.write_uint16(0, static_cast<uint16_t>(buf.size()), pHead->byteOrder()); |
| 930 | pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf)); |
| 931 | } else { |
| 932 | pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_); |
| 933 | } |
| 934 | } // CrwMap::encodeArray |
| 935 | |
| 936 | void CrwMap::encode0x180e(const Image& image, const CrwMapping* pCrwMapping, CiffHeader* pHead) { |
| 937 | time_t t = 0; |