Exemple #1
0
void Writer::setDEWriteHandlers(nitf::IOHandle& io, nitf::Record& record)
{
    nitf::List dataExtensions = record.getDataExtensions();
    const size_t numDEs = record.getNumDataExtensions();
    for (size_t ii = 0; ii < numDEs; ++ii)
    {
       nitf::DESegment segment = dataExtensions[ii];
       const size_t offset = segment.getOffset();
       mem::SharedPtr< ::nitf::WriteHandler> handler(
           new nitf::StreamIOWriteHandler (
               io, offset, segment.getEnd() - offset));
       setDEWriteHandler(ii, handler);
    }
}
Exemple #2
0
void Writer::setTextWriteHandlers(nitf::IOHandle& io, nitf::Record& record)
{
    nitf::List texts = record.getTexts();
    const size_t numTexts = record.getNumTexts();
    for (size_t ii = 0; ii < numTexts; ++ii)
    {
       nitf::TextSegment segment = texts[ii];
       const size_t offset = segment.getOffset();
       mem::SharedPtr< ::nitf::WriteHandler> handler(
           new nitf::StreamIOWriteHandler (
               io, offset, segment.getEnd() - offset));
       setTextWriteHandler(ii, handler);
    }
}
Exemple #3
0
void Writer::setGraphicWriteHandlers(nitf::IOHandle& io, nitf::Record& record)
{
    nitf::List graphics = record.getGraphics();
    const size_t numGraphics = record.getNumGraphics();
    for (size_t ii = 0; ii < numGraphics; ++ii)
    {
       nitf::GraphicSegment segment = graphics[ii];
       long offset = segment.getOffset();
       mem::SharedPtr< ::nitf::WriteHandler> handler(
           new nitf::StreamIOWriteHandler (
               io, offset, segment.getEnd() - offset));
       setGraphicWriteHandler(ii, handler);
    }
}
Exemple #4
0
void Writer::setImageWriteHandlers(nitf::IOHandle& io, nitf::Record& record)
{
    nitf::List images = record.getImages();
    const size_t numImages = record.getNumImages();
    for (size_t ii = 0; ii < numImages; ++ii)
    {
        nitf::ImageSegment segment = images[ii];
        const size_t offset = segment.getImageOffset();
        mem::SharedPtr<nitf::WriteHandler> handler(
                new nitf::StreamIOWriteHandler(
                    io, offset, segment.getImageEnd() - offset));
        setImageWriteHandler(ii, handler);
    }
}
void doWrite(nitf::Record record,
             const std::string& inRootFile,
             const std::string& outFile,
             size_t bufferSize)
{
    std::cout << "Preparing to write file in " << bufferSize
              << " size blocks" << std::endl;

    nitf::BufferedWriter output(outFile, bufferSize);
    nitf::Writer writer;
    writer.prepareIO(output, record);

    int numImages = record.getHeader().getNumImages();
    nitf::ListIterator end = record.getImages().end();
    nitf::ListIterator iter = record.getImages().begin();

    for (int i = 0; i < numImages && iter != end; ++i, ++iter)
    {
        nitf::ImageSegment imseg;
        imseg = *iter;
        int nbands = imseg.getSubheader().getNumImageBands();
        nitf::ImageWriter iWriter = writer.newImageWriter(i);
        nitf::ImageSource iSource = setupBands(nbands, i, inRootFile);
        iWriter.attachSource(iSource);
    }
    writer.write();
    //output.close();

    std::cout << "Write block info: " << std::endl;
    std::cout << "------------------------------------" << std::endl;
    std::cout << "Total number of blocks written: " << output.getNumBlocksWritten() << std::endl;
    std::cout << "Of those, " << output.getNumPartialBlocksWritten() << " were less than buffer size " << bufferSize << std::endl;



}
Exemple #6
0
void Writer::prepareIO(nitf::IOInterface & io, nitf::Record & record)
        throw (nitf::NITFException)
{
    NITF_BOOL x = nitf_Writer_prepareIO(getNativeOrThrow(), record.getNative(),
                                        io.getNative(), &error);

    // It's possible prepareIO() failed but actually took ownership of one
    // or both of these objects.  So we need to call setManaged() on them
    // properly regardless of if the function succeeded.
    if (getNativeOrThrow()->record == record.getNative())
    {
        record.setManaged(true);
    }

    if (getNativeOrThrow()->output == io.getNative())
    {
        io.setManaged(true);
    }

    if (!x)
    {
        throw nitf::NITFException(&error);
    }
}