Ejemplo n.º 1
0
    void TiffParser::decode(Image*             pImage,
                            const byte*        pData,
                            uint32_t           size,
                            TiffCompFactoryFct createFct,
                            FindDecoderFct     findDecoderFct,
			    TiffHeaderBase*    pHeader)
    {
        assert(pImage != 0);
        assert(pData != 0);

        std::auto_ptr<TiffHeaderBase> ph;
        if (!pHeader) {
            ph = std::auto_ptr<TiffHeaderBase>(new TiffHeade2);
            pHeader = ph.get();
        }

        if (!pHeader->read(pData, size) || pHeader->offset() >= size) {
            throw Error(3, "TIFF");
        }
        TiffComponent::AutoPtr rootDir = createFct(Tag::root, Group::none);
        if (0 == rootDir.get()) return;
        rootDir->setStart(pData + pHeader->offset());

        TiffRwState::AutoPtr state(
            new TiffRwState(pHeader->byteOrder(), 0, createFct));
        TiffReader reader(pData, size, rootDir.get(), state);
        rootDir->accept(reader);

        TiffMetadataDecoder decoder(pImage, rootDir.get(), findDecoderFct, 4096);
        rootDir->accept(decoder);

    } // TiffParser::decode
Ejemplo n.º 2
0
    TiffComponent::AutoPtr TiffParserWorker::parse(
        const byte*              pData,
              uint32_t           size,
              TiffCompFactoryFct createFct,
              TiffHeaderBase*    pHeader
    )
    {
        if (pData == 0 || size == 0) return TiffComponent::AutoPtr(0);
        if (!pHeader->read(pData, size) || pHeader->offset() >= size) {
            throw Error(3, "TIFF");
        }
        TiffComponent::AutoPtr rootDir = createFct(Tag::root, Group::none);
        if (0 != rootDir.get()) {
            rootDir->setStart(pData + pHeader->offset());
            TiffRwState::AutoPtr state(
                new TiffRwState(pHeader->byteOrder(), 0, createFct));
            TiffReader reader(pData, size, rootDir.get(), state);
            rootDir->accept(reader);
        }
        return rootDir;

    } // TiffParserWorker::parse