Пример #1
0
 void CrwMap::extractBasic(const CiffComponent& ciffComponent,
                           const CrwMapInfo* crwMapInfo,
                           Image& image,
                           ByteOrder byteOrder)
 {
     // create a key and value pair
     ExifKey key(crwMapInfo->tag_, ExifTags::ifdItem(crwMapInfo->ifdId_));
     Value::AutoPtr value;
     if (ciffComponent.typeId() != directory) {
         value = Value::create(ciffComponent.typeId());
         uint32_t size = 0;
         if (crwMapInfo->size_ != 0) {
             // size in the mapping table overrides all
             size = crwMapInfo->size_;
         }
         else if (ciffComponent.typeId() == asciiString) {
             // determine size from the data, by looking for the first 0
             uint32_t i = 0;
             for (;    i < ciffComponent.size()
                    && ciffComponent.pData()[i] != '\0'; ++i) {
                 // empty
             }
             size = ++i;
         }
         else {
             // by default, use the size from the directory entry
             size = ciffComponent.size();
         }
         value->read(ciffComponent.pData(), size, byteOrder);
     }
     // Add metadatum to exif data
     image.exifData().add(key, value.get());
 } // CrwMap::extractBasic
Пример #2
0
void processAdd(const std::string& line, int num, IptcData &iptcData)
{
    std::string::size_type keyStart = line.find_first_not_of(" \t", 1);
    std::string::size_type keyEnd = line.find_first_of(" \t", keyStart+1);
    std::string::size_type dataStart = line.find_first_not_of(" \t", keyEnd+1);

    if (keyStart == std::string::npos ||
        keyEnd == std::string::npos ||
        dataStart == std::string::npos) {
        std::ostringstream os;
        os << "Invalid \'a\' command at line " << num;
        throw Error(1, os.str());
    }

    std::string key(line.substr(keyStart, keyEnd-keyStart));
    IptcKey iptcKey(key);

    std::string data(line.substr(dataStart));
    // if data starts and ends with quotes, remove them
    if (data.at(0) == '\"' && data.at(data.size()-1) == '\"') {
        data = data.substr(1, data.size()-2);
    }
    TypeId type = IptcDataSets::dataSetType(iptcKey.tag(), iptcKey.record());
    Value::AutoPtr value = Value::create(type);
    value->read(data);

    int rc = iptcData.add(iptcKey, value.get());
    if (rc) {
        throw Error(1, "Iptc dataset already exists and is not repeatable");
    }
}
Пример #3
0
 int IptcData::readData(uint16_t dataSet, uint16_t record, 
                        const byte* data, uint32_t sizeData)
 {
     Value::AutoPtr value;
     TypeId type = IptcDataSets::dataSetType(dataSet, record);
     value = Value::create(type);
     value->read(data, sizeData, bigEndian);
     IptcKey key(dataSet, record);
     add(key, value.get());
     return 0;
 }
Пример #4
0
 int IptcData::readData(uint16_t dataSet, uint16_t record,
                        const byte* data, uint32_t sizeData)
 {
     Value::AutoPtr value;
     TypeId type = IptcDataSets::dataSetType(dataSet, record);
     value = Value::create(type);
     int rc = value->read(data, sizeData, bigEndian);
     if (0 == rc) {
         IptcKey key(dataSet, record);
         add(key, value.get());
     }
     else if (1 == rc) {
         // If the first attempt failed, try with a string value
         value = Value::create(string);
         int rc = value->read(data, sizeData, bigEndian);
         if (0 == rc) {
             IptcKey key(dataSet, record);
             add(key, value.get());
         }
     }
     return rc;
 }
Пример #5
0
    void CiffComponent::print(std::ostream& os,
                             ByteOrder byteOrder,
                             const std::string& prefix) const
    {
        os << prefix
           << "tag = 0x" << std::setw(4) << std::setfill('0')
           << std::hex << std::right << tagId()
           << ", dir = 0x" << std::setw(4) << std::setfill('0')
           << std::hex << std::right << dir()
           << ", type = " << TypeInfo::typeName(typeId())
           << ", size = " << std::dec << size_
           << ", offset = " << offset_ << "\n";

        Value::AutoPtr value;
        if (typeId() != directory) {
            value = Value::create(typeId());
            value->read(pData_, size_, byteOrder);
            if (value->size() < 100) {
                os << prefix << *value << "\n";
            }
        }
    } // CiffComponent::print