void Editor::copy() { Layer* layer = mObject->getLayer(layers()->currentLayerIndex()); if (layer == nullptr) { return; } if (layer->type() == Layer::BITMAP) { LayerBitmap* layerBitmap = static_cast<LayerBitmap*>(layer); if (mScribbleArea->isSomethingSelected()) { g_clipboardBitmapImage = layerBitmap->getLastBitmapImageAtFrame(currentFrame(), 0)->copy(mScribbleArea->getSelection().toRect()); // copy part of the image } else { g_clipboardBitmapImage = layerBitmap->getLastBitmapImageAtFrame(currentFrame(), 0)->copy(); // copy the whole image } clipboardBitmapOk = true; if (g_clipboardBitmapImage.image() != nullptr) QApplication::clipboard()->setImage(*g_clipboardBitmapImage.image()); } if (layer->type() == Layer::VECTOR) { clipboardVectorOk = true; g_clipboardVectorImage = *((static_cast<LayerVector*>(layer))->getLastVectorImageAtFrame(currentFrame(), 0)); // copy the image } }
LayerBitmap* LayerManager::createBitmapLayer( const QString& strLayerName ) { LayerBitmap* layer = editor()->object()->addNewBitmapLayer(); layer->setName( strLayerName ); Q_EMIT layerCountChanged( count() ); return layer; }
//void Object::paintImage(QPainter &painter, int frameNumber, const QRectF &source, const QRectF &target, bool background, qreal curveOpacity, bool antialiasing, bool niceGradients) { void Object::paintImage(QPainter& painter, int frameNumber, bool background, qreal curveOpacity, bool antialiasing, int gradients) { painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); //painter.setWorldMatrix(matrix); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); // paints the background if (background) { painter.setPen(Qt::NoPen); painter.setBrush(Qt::white); painter.setWorldMatrixEnabled(false); painter.drawRect( QRect(0,0, painter.device()->width(), painter.device()->height() ) ); painter.setWorldMatrixEnabled(true); } for(int i=0; i < getLayerCount(); i++) { Layer* layer = getLayer(i); if (layer->visible) { painter.setOpacity(1.0); // paints the bitmap images if (layer->type == Layer::BITMAP) { LayerBitmap* layerBitmap = (LayerBitmap*)layer; /*BitmapImage* bitmapImage = layerBitmap->getLastBitmapImageAtFrame(frameNumber, 0); // TO BE FIXED if (bitmapImage != NULL) { if ( mirror) { painter.drawImage(target, (*(bitmapImage->image)).mirrored(true, false), source); } else { painter.drawImage(target, *(bitmapImage->image), source); } }*/ layerBitmap->getLastBitmapImageAtFrame(frameNumber, 0)->paintImage(painter); } // paints the vector images if (layer->type == Layer::VECTOR) { LayerVector* layerVector = (LayerVector*)layer; layerVector->getLastVectorImageAtFrame(frameNumber, 0)->paintImage(painter, false, false, curveOpacity, antialiasing, gradients); } } } }
void Object::paintImage( QPainter& painter, int frameNumber, bool background, bool antialiasing ) { painter.setRenderHint( QPainter::Antialiasing, true ); painter.setRenderHint( QPainter::SmoothPixmapTransform, true ); //painter.setTransform(matrix); painter.setCompositionMode( QPainter::CompositionMode_SourceOver ); // paints the background if ( background ) { painter.setPen( Qt::NoPen ); painter.setBrush( Qt::white ); painter.setWorldMatrixEnabled( false ); painter.drawRect( QRect( 0, 0, painter.device()->width(), painter.device()->height() ) ); painter.setWorldMatrixEnabled( true ); } for ( int i = 0; i < getLayerCount(); i++ ) { Layer* layer = getLayer( i ); if ( layer->visible ) { painter.setOpacity( 1.0 ); // paints the bitmap images if ( layer->type() == Layer::BITMAP ) { LayerBitmap* layerBitmap = ( LayerBitmap* )layer; layerBitmap->getLastBitmapImageAtFrame( frameNumber, 0 )->paintImage( painter ); } // paints the vector images if ( layer->type() == Layer::VECTOR ) { LayerVector* layerVector = ( LayerVector* )layer; layerVector->getLastVectorImageAtFrame( frameNumber, 0 )->paintImage( painter, false, false, antialiasing ); } } } }
void CanvasRenderer::paintBitmapFrame( QPainter& painter, int layerId, int nFrame, bool colorize, bool useLastKeyFrame ) { Layer* layer = mObject->getLayer( layerId ); if ( !layer->visible() ) { return; } LayerBitmap* bitmapLayer = dynamic_cast< LayerBitmap* >( layer ); if ( bitmapLayer == nullptr ) { Q_ASSERT( bitmapLayer ); return; } qCDebug( mLog ) << "Paint Onion skin bitmap, Frame = " << nFrame; BitmapImage* bitmapImage; if (useLastKeyFrame) { bitmapImage = bitmapLayer->getLastBitmapImageAtFrame( nFrame, 0 ); } else { bitmapImage = bitmapLayer->getBitmapImageAtFrame( nFrame ); } if ( bitmapImage == nullptr ) { return; } BitmapImage* tempBitmapImage = new BitmapImage; tempBitmapImage->paste(bitmapImage); if ( colorize ) { QBrush colorBrush = QBrush(Qt::transparent); //no color for the current frame if (nFrame < mFrameNumber) { colorBrush = QBrush(Qt::red); } else if (nFrame > mFrameNumber) { colorBrush = QBrush(Qt::blue); } tempBitmapImage->drawRect( bitmapImage->bounds(), Qt::NoPen, colorBrush, QPainter::CompositionMode_SourceIn, false); } // If the current frame on the current layer has a transformation, we apply it. // if (mRenderTransform && nFrame == mFrameNumber && layerId == mLayerIndex ) { tempBitmapImage->clear(mSelection); paintTransformedSelection(painter); } painter.setWorldMatrixEnabled( true ); if (mRenderTransform && nFrame) { painter.setOpacity( bitmapLayer->getOpacity() ); } tempBitmapImage->paintImage( painter ); delete tempBitmapImage; }