示例#1
0
Natron::StatusEnum
QtWriter::render(SequenceTime time,
                 const RenderScale& /*originalScale*/,
                 const RenderScale & mappedScale,
                 const RectI & roi,
                 int view,
                 bool /*isSequentialRender*/,
                 bool /*isRenderResponseToUserInteraction*/,
                 boost::shared_ptr<Natron::Image> output)
{
    boost::shared_ptr<Natron::Image> src = getImage(0, time, mappedScale, view, NULL, output->getComponents(), output->getBitDepth(),1, false,NULL);

    if ( hasOutputConnected() ) {
        output->pasteFrom( *src, src->getBounds() );
    }

    ////initializes to black
    unsigned char* buf = (unsigned char*)calloc(roi.area() * 4,1);
    QImage::Format type;
    bool premult = _premultKnob->getValue();
    if (premult) {
        type = QImage::Format_ARGB32_Premultiplied;
    } else {
        type = QImage::Format_ARGB32;
    }

    _lut->to_byte_packed(buf, (const float*)src->pixelAt(0, 0), roi, src->getBounds(), roi,
                         Natron::Color::PACKING_RGBA, Natron::Color::PACKING_BGRA, true, premult);

    QImage img(buf,roi.width(),roi.height(),type);
    std::string filename = _fileKnob->getValue();
    filename = filenameFromPattern( filename,std::floor(time + 0.5) );

    img.save( filename.c_str() );
    free(buf);

    return eStatusOK;
}