Ejemplo n.º 1
0
nitf::FileSource::FileSource(nitf::IOHandle & io,
                             nitf::Off start,
                             int numBytesPerPixel,
                             int pixelSkip) throw(nitf::NITFException)
{
    setNative(nitf_IOSource_construct(io.getNative(), start, numBytesPerPixel, pixelSkip, &error));
    setManaged(false);
    io.setManaged(true); //TODO must release this on destruction
}
Ejemplo n.º 2
0
NITFAPI(nitf_BandSource *) nitf_FileSource_constructFile(const char* fname,
                                                         nitf_Off start,
                                                         int numBytesPerPixel,
                                                         int pixelSkip,
                                                         nitf_Error* error)
{
    /* We need a way to free 'interface' when we destruct - the IOSource
     * doesn't take ownership of it.
     */
    static nitf_IDataSource iFileSource =
    {
        &IOSource_read,
        &FileSource_destruct,
        &IOSource_getSize,
        &IOSource_setSize
    };

    nitf_IOInterface* interface = NULL;
    nitf_BandSource* bandSource = NULL;

    interface = nitf_IOHandleAdapter_open(fname, NRT_ACCESS_READONLY,
                                          NRT_OPEN_EXISTING, error);
    if (interface == NULL)
    {
        return NULL;
    }

    bandSource = nitf_IOSource_construct(interface, start, numBytesPerPixel,
                                         pixelSkip, error);
    if (bandSource == NULL)
    {
        return NULL;
    }

    bandSource->iface = &iFileSource;
    return bandSource;
}