Пример #1
0
void SnapshotAnimated::processFrames() {
    uint32_t width = SnapshotAnimated::snapshotAnimatedFrameVector[0].width();
    uint32_t height = SnapshotAnimated::snapshotAnimatedFrameVector[0].height();

    // Create the GIF from the temporary files
    // Write out the header and beginning of the GIF file
    GifBegin(
        &(SnapshotAnimated::snapshotAnimatedGifWriter),
        qPrintable(SnapshotAnimated::snapshotAnimatedPath),
        width,
        height,
        1); // "1" means "yes there is a delay" with this GifCreator library.
    for (int itr = 0; itr < SnapshotAnimated::snapshotAnimatedFrameVector.size(); itr++) {
        // Write each frame to the GIF
        GifWriteFrame(&(SnapshotAnimated::snapshotAnimatedGifWriter),
            (uint8_t*)SnapshotAnimated::snapshotAnimatedFrameVector[itr].convertToFormat(QImage::Format_RGBA8888).bits(),
            width,
            height,
            SnapshotAnimated::snapshotAnimatedFrameDelayVector[itr]);
    }
    // Write out the end of the GIF
    GifEnd(&(SnapshotAnimated::snapshotAnimatedGifWriter));

    // Clear out the frame and frame delay vectors.
    // Also release the memory not required to store the items.
    SnapshotAnimated::snapshotAnimatedFrameVector.clear();
    SnapshotAnimated::snapshotAnimatedFrameVector.squeeze();
    SnapshotAnimated::snapshotAnimatedFrameDelayVector.clear();
    SnapshotAnimated::snapshotAnimatedFrameDelayVector.squeeze();

    // Let the dependency manager know that the snapshots have been taken.
    emit SnapshotAnimated::snapshotAnimatedDM->snapshotTaken(SnapshotAnimated::snapshotStillPath, SnapshotAnimated::snapshotAnimatedPath, false);
}
Пример #2
0
bool
GIFOutput::finish_subimage()
{
    if (!m_pending_write)
        return true;

    bool ok         = GifWriteFrame(&m_gifwriter, &m_canvas[0], spec().width,
                            spec().height, m_delay, 8 /*bitdepth*/,
                            true /*dither*/);
    m_pending_write = false;
    return ok;
}
Пример #3
0
void GifSaver::save()
{
    std::vector< uint8_t* > bufferVector;
    GifWriter gifWriter;
    GifBegin( &gifWriter, _outputFilePath.toStdString().c_str(),
              _inputAnimatedGif[ 0 ]->getWidth() * _scaleFactor,
              _inputAnimatedGif[ 0 ]->getHeight() * _scaleFactor,
              10 );

    int i = 0;
    for( const auto& frame : _inputAnimatedGif )
    {
        _filter->setNewInputImage( frame );
        _filter->apply();

        Image* outputFrame = new Image( new QImage( *( _filter->getOutputImage()->getQImage() ) ) );

        const int rgbaSize = 4;
        uint8_t* outputFrameBuffer = new uint8_t[ outputFrame->getWidth() * outputFrame->getHeight() * rgbaSize ];

        outputFrame->getBufferRGBA8( outputFrameBuffer );

        bufferVector.push_back( outputFrameBuffer );

        GifWriteFrame( &gifWriter,
                       outputFrameBuffer,
                       outputFrame->getWidth(),
                       outputFrame->getHeight(), 10 );

        delete outputFrame;
        delete[] outputFrameBuffer;

        emit setProgress( ( float ) i++ * 100 / _inputAnimatedGif.size() );
    }

    GifEnd( &gifWriter );
}
Пример #4
0
static bool gif_write_frame(GifWriter *frameWriter, unsigned int delay) {
    return GifWriteFrame(frameWriter, renderFramebuffer(&lcd).convertToFormat(QImage::Format_RGBA8888).bits(), 320, 240, delay);
}