コード例 #1
0
ファイル: djvPngLoad.cpp プロジェクト: mottosso/djv
void djvPngLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvPngLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    image.colorProfile = djvColorProfile();
    image.tags = djvImageTags();

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    //DJV_DEBUG_PRINT("file name = " << fileName);

    djvImageIoInfo info;
    _open(fileName, info);

    // Read the file.

    djvPixelData * data = frame.proxy ? &_tmp : &image;
    
    data->set(info);

    for (int y = 0; y < info.size.y; ++y)
    {
        if (! pngScanline(_png, data->data(0,  data->h() - 1 - y)))
        {
            throw djvError(
                djvPng::staticName,
                _pngError.msg);
        }
    }

    pngEnd(_png, _pngInfoEnd);

    // Proxy scale the image.
    
    if (frame.proxy)
    {
        info.size = djvPixelDataUtil::proxyScale(info.size, frame.proxy);
        info.proxy = frame.proxy;
        
        image.set(info);

        djvPixelDataUtil::proxyScale(_tmp, image, frame.proxy);
    }

    //DJV_DEBUG_PRINT("image = " << image);
    
    close();
}
コード例 #2
0
ファイル: djvLutLoad.cpp プロジェクト: mottosso/djv
void djvLutLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvLutLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    image.colorProfile = djvColorProfile();
    image.tags = djvImageTags();

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    djvImageIoInfo info;
    
    djvFileIo io;
    
    _open(fileName, info, io);

    // Read the file.

    image.set(info);

    switch (_format)
    {
        case djvLut::FORMAT_INFERNO:
            djvLut::infernoLoad(io, image);
            break;
        
        case djvLut::FORMAT_KODAK:
            djvLut::kodakLoad(io, image);
            break;

        default: break;
    }

    //DJV_DEBUG_PRINT("image = " << image);
}
コード例 #3
0
ファイル: djvDpxLoad.cpp プロジェクト: mottosso/djv
void djvDpxLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvDpxLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    //DJV_DEBUG_PRINT("file name = " << fileName);

    djvImageIoInfo info;
    
    QScopedPointer<djvFileIo> io(new djvFileIo);
    
    _open(fileName, info, *io);

    image.tags = info.tags;
    
    // Set the color profile.

    if ((djvCineon::COLOR_PROFILE_FILM_PRINT == _options.inputColorProfile) ||
        (djvCineon::COLOR_PROFILE_AUTO == _options.inputColorProfile &&
            _filmPrint))
    {
        //DJV_DEBUG_PRINT("color profile");

        image.colorProfile.type = djvColorProfile::LUT;

        if (! _filmPrintLut.isValid())
        {
            _filmPrintLut = djvCineon::filmPrintToLinearLut(
                _options.inputFilmPrint);
        }

        image.colorProfile.lut = _filmPrintLut;
    }
    else
    {
        image.colorProfile = djvColorProfile();
    }

    // Read the file.

    io->readAhead();

    bool mmap = true;

    if ((io->size() - io->pos()) < djvPixelDataUtil::dataByteCount(info))
    {
        mmap = false;
    }
    
    //DJV_DEBUG_PRINT("mmap = " << mmap);
    
    if (mmap)
    {
        if (! frame.proxy)
        {
            image.set(info, io->mmapP(), io.data());

            io.take();
        }
        else
        {
            _tmp.set(info, io->mmapP());

            info.size = djvPixelDataUtil::proxyScale(info.size, frame.proxy);
            info.proxy = frame.proxy;

            image.set(info);

            djvPixelDataUtil::proxyScale(_tmp, image, frame.proxy);
        }
    }
    else
    {
        djvPixelData * data = frame.proxy ? &_tmp : &image;
        data->set(info);
        
        djvError error;
        bool     errorValid = false;
        
        try
        {
            for (int y = 0; y < info.size.y; ++y)
            {
                io->get(
                    data->data(0, y),
                    info.size.x * djvPixel::byteCount(info.pixel));
            }
        }
        catch (const djvError & otherError)
        {
            error      = otherError;
            errorValid = true;
        }
        
        if (frame.proxy)
        {
            info.size = djvPixelDataUtil::proxyScale(info.size, frame.proxy);
            info.proxy = frame.proxy;

            image.set(info);

            djvPixelDataUtil::proxyScale(_tmp, image, frame.proxy);
        }
        
        if (errorValid)
            throw error;
    }
    
    //DJV_DEBUG_PRINT("image = " << image);
}
コード例 #4
0
ファイル: djvTargaLoad.cpp プロジェクト: mottosso/djv
void djvTargaLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvTargaLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    image.colorProfile = djvColorProfile();
    image.tags = djvImageTags();

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    //DJV_DEBUG_PRINT("file name = " << fileName);

    djvImageIoInfo info;
    
    QScopedPointer<djvFileIo> io(new djvFileIo);
    
    _open(fileName, info, *io);

    // Read the file.

    io->readAhead();

    djvPixelData * data = frame.proxy ? &_tmp : &image;

    if (! _compression)
    {
        if ((io->size() - io->pos()) < djvPixelDataUtil::dataByteCount(info))
        {
            throw djvError(
                djvTarga::staticName,
                djvImageIo::errorLabels()[djvImageIo::ERROR_READ]);
        }

        data->set(info, io->mmapP(), io.data());

        io.take();
    }
    else
    {
        data->set(info);

        const quint8 * p = io->mmapP();
        
        const quint8 * const end = io->mmapEnd();
        
        const int channels = djvPixel::channels(info.pixel);

        for (int y = 0; y < info.size.y; ++y)
        {
            //DJV_DEBUG_PRINT("y = " << y);

            p = djvTarga::readRle(
                p,
                end,
                data->data(0, y),
                info.size.x,
                channels);

            if (! p)
            {
                throw djvError(
                    djvTarga::staticName,
                    djvImageIo::errorLabels()[djvImageIo::ERROR_READ]);
            }
        }
    }

    // Proxy scale the image.
    
    if (frame.proxy)
    {
        info.size = djvPixelDataUtil::proxyScale(info.size, frame.proxy);
        info.proxy = frame.proxy;
        
        image.set(info);

        djvPixelDataUtil::proxyScale(_tmp, image, frame.proxy);
    }

    //DJV_DEBUG_PRINT("image = " << image);
}
コード例 #5
0
ファイル: djvSgiLoad.cpp プロジェクト: mottosso/djv
void djvSgiLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvSgiLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    image.colorProfile = djvColorProfile();
    image.tags = djvImageTags();

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    //DJV_DEBUG_PRINT("file name = " << fileName);

    djvImageIoInfo info;
    
    djvFileIo io;
    
    _open(fileName, info, io);

    // Read the file.

    io.readAhead();

    const quint64 pos      = io.pos();
    const quint64 size     = io.size() - pos;
    const int     channels = djvPixel::channels(info.pixel);
    const int     bytes    = djvPixel::channelByteCount(info.pixel);

    if (! _compression)
    {
        if (1 == bytes)
        {
            const quint8 * p = io.mmapP();
            
            io.seek(djvPixelDataUtil::dataByteCount(info));
            
            _tmp.set(info, p);
        }
        else
        {
            if (size != djvPixelDataUtil::dataByteCount(info))
            {
                throw djvError(
                    djvSgi::staticName,
                    djvImageIo::errorLabels()[djvImageIo::ERROR_READ]);
            }
        
            _tmp.set(info);
            
            io.get(_tmp.data(), size / bytes, bytes);
        }
    }
    else
    {
        _tmp.set(info);

        djvMemoryBuffer<quint8> tmp(size);
        
        io.get(tmp(), size / bytes, bytes);

        const quint8 * inP  = tmp();
        const quint8 * end  = inP + size;
        quint8 *       outP = _tmp.data();

        for (int c = 0; c < channels; ++c)
        {
            //DJV_DEBUG_PRINT("channel = " << c);

            for (int y = 0; y < info.size.y; ++y, outP += info.size.x * bytes)
            {
                //DJV_DEBUG_PRINT("y = " << y);

                if (! djvSgi::readRle(
                    inP + _rleOffset()[y + info.size.y * c] - pos,
                    end,
                    outP,
                    info.size.x,
                    bytes,
                    io.endian()))
                {
                    throw djvError(
                        djvSgi::staticName,
                        djvImageIo::errorLabels()[djvImageIo::ERROR_READ]);
                }
            }
        }
    }

    // Interleave the image channels.

    info.size = djvPixelDataUtil::proxyScale(info.size, frame.proxy);
    info.proxy = frame.proxy;
    image.set(info);

    djvPixelDataUtil::planarInterleave(_tmp, image, frame.proxy);

    //DJV_DEBUG_PRINT("image = " << image);
}
コード例 #6
0
ファイル: djvRlaLoad.cpp プロジェクト: mottosso/djv
void djvRlaLoad::read(djvImage & image, const djvImageIoFrameInfo & frame)
    throw (djvError)
{
    //DJV_DEBUG("djvRlaLoad::read");
    //DJV_DEBUG_PRINT("frame = " << frame);

    image.colorProfile = djvColorProfile();
    image.tags = djvImageTags();

    // Open the file.

    const QString fileName =
        _file.fileName(frame.frame != -1 ? frame.frame : _file.sequence().start());

    //DJV_DEBUG_PRINT("file name = " << fileName);

    djvImageIoInfo info;
    
    djvFileIo io;
    
    _open(fileName, info, io);

    if (frame.layer < 0 || frame.layer >= info.layerCount())
    {
        throw djvError(
            djvRla::staticName,
            djvImageIo::errorLabels()[djvImageIo::ERROR_READ]);
    }

    djvPixelDataInfo _info = info[frame.layer];

    // Read the file.

    io.readAhead();

    djvPixelData * p = frame.proxy ? &_tmp : &image;
    
    p->set(_info);

    const int w        = _info.size.x;
    const int h        = _info.size.y;
    const int channels = djvPixel::channels(_info.pixel);
    const int bytes    = djvPixel::channelByteCount(_info.pixel);

    //DJV_DEBUG_PRINT("channels = " << channels);
    //DJV_DEBUG_PRINT("bytes = " << bytes);

    quint8 * data_p = p->data();

    for (int y = 0; y < h; ++y, data_p += w * channels * bytes)
    {
        io.setPos(_rleOffset()[y]);

        for (int c = 0; c < channels; ++c)
        {
            if (djvPixel::F32 == djvPixel::type(_info.pixel))
            {
                djvRla::floatLoad(io, data_p + c * bytes, w, channels);
            }
            else
            {
                djvRla::readRle(io, data_p + c * bytes, w, channels, bytes);
            }
        }
    }

    // Proxy scale the image.
    
    if (frame.proxy)
    {
        _info.size = djvPixelDataUtil::proxyScale(_info.size, frame.proxy);
        _info.proxy = frame.proxy;
        
        image.set(_info);

        djvPixelDataUtil::proxyScale(_tmp, image, frame.proxy);
    }

    //DJV_DEBUG_PRINT("image = " << image);
}