//Image loading is Done.
//File Crop Code
void FileCropper::onFileCrop()
{
myLeft=ui->myLeftSpinBox->value();
myRight=ui->myRightSpinBox->value();
myTop=ui->myTopSpinBox->value();
myBottom=ui->myBottomSpinBox->value();
QPixmap pixmap
= myBeforePixItem
->pixmap
();
QRectF newRect
= myRectItem
->rect
();
QPointF point
= myRectItem
->scenePos
();
float x = point.x();
float y = point.y();
QRectF moveRect
( x
+ newRect.
left() , y
+ newRect.
top() , newRect.
width(), newRect.
height() );
qDebug()<<"X:"<<x;
qDebug()<<"Y:"<<y;
QPixmap newImage
= pixmap.
copy( moveRect.
toRect() );
myAfterScene.setSceneRect( 0, 0, newRect.width(), newRect.height());
ui->myAfterGraphicsVew->fitInView(myAfterScene.sceneRect(),Qt::KeepAspectRatio);
ui->myAfterGraphicsVew->centerOn(newRect.width()/2,newRect.height()/2);
myAfterPixItem->setPixmap( newImage );
}
//my Rect Code
void FileCropper::onChange()
{
myLeft=ui->myLeftSpinBox->value();
myRight=ui->myRightSpinBox->value();
myTop=ui->myTopSpinBox->value();
myBottom=ui->myBottomSpinBox->value();
QPixmap pixmap
= myBeforePixItem
->pixmap
();
QRectF newRect
( myLeft, myTop, pixmap.
width() - myLeft
-myRight, pixmap.
height() - myTop
-myBottom
);
myRectItem->setRect( newRect );
}
//Rotate Code
void FileCropper::onRotate(int val)
{
QRectF rotateRect
(0,
0,myBeforePixItem
->pixmap
().
width(),myBeforePixItem
->pixmap
().
height());
QTransform t;
t.translate(rotateRect.center().x(),rotateRect.center().y());
t.rotate(val);
t.translate(-rotateRect.center().x(),-rotateRect.center().y());
myRectItem->setTransform(t,false);
}
//Image loading is Done.
//File Crop Code
void FileCropper::onFileCrop()
{
myLeft=ui->myLeftSpinBox->value();
myRight=ui->myRightSpinBox->value();
myTop=ui->myTopSpinBox->value();
myBottom=ui->myBottomSpinBox->value();
QPixmap pixmap = myBeforePixItem->pixmap();
QRectF newRect = myRectItem->rect();
QPointF point = myRectItem->scenePos();
float x = point.x();
float y = point.y();
QRectF moveRect( x + newRect.left() , y + newRect.top() , newRect.width(), newRect.height() );
qDebug()<<"X:"<<x;
qDebug()<<"Y:"<<y;
QPixmap newImage = pixmap.copy( moveRect.toRect() );
myAfterScene.setSceneRect( 0, 0, newRect.width(), newRect.height());
ui->myAfterGraphicsVew->fitInView(myAfterScene.sceneRect(),Qt::KeepAspectRatio);
ui->myAfterGraphicsVew->centerOn(newRect.width()/2,newRect.height()/2);
myAfterPixItem->setPixmap( newImage );
}
//my Rect Code
void FileCropper::onChange()
{
myLeft=ui->myLeftSpinBox->value();
myRight=ui->myRightSpinBox->value();
myTop=ui->myTopSpinBox->value();
myBottom=ui->myBottomSpinBox->value();
QPixmap pixmap = myBeforePixItem->pixmap();
QRectF newRect( myLeft, myTop, pixmap.width() - myLeft -myRight, pixmap.height() - myTop -myBottom );
myRectItem->setRect( newRect );
}
//Rotate Code
void FileCropper::onRotate(int val)
{
QRectF rotateRect(0,0,myBeforePixItem->pixmap().width(),myBeforePixItem->pixmap().height());
QTransform t;
t.translate(rotateRect.center().x(),rotateRect.center().y());
t.rotate(val);
t.translate(-rotateRect.center().x(),-rotateRect.center().y());
myRectItem->setTransform(t,false);
}
To copy to clipboard, switch view to plain text mode
Bookmarks