From f93aa5601d1bda84ea33a67bfc811a83963adc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9au?= <theau.baton@etu.univ-amu.fr> Date: Fri, 2 Feb 2024 18:48:11 +0100 Subject: [PATCH] Correction du rognage --- IHM_Retouche_Photo/dialog/resizedialog.cpp | 11 +++++++++ IHM_Retouche_Photo/mainwindow.cpp | 1 - IHM_Retouche_Photo/tools/editable/bucket.cpp | 2 +- .../tools/selectionable/ellipse.cpp | 2 +- .../ui/menu/imagemenulambda.cpp | 14 +++++------ IHM_Retouche_Photo/ui/menu/imagemenulambda.h | 4 ++-- IHM_Retouche_Photo/ui/view/imagearea.cpp | 24 ++++++++++--------- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/IHM_Retouche_Photo/dialog/resizedialog.cpp b/IHM_Retouche_Photo/dialog/resizedialog.cpp index 88363a6..464fb7c 100644 --- a/IHM_Retouche_Photo/dialog/resizedialog.cpp +++ b/IHM_Retouche_Photo/dialog/resizedialog.cpp @@ -15,9 +15,20 @@ namespace dialog { ui::ImageArea * area = this->_viewManager->currentView(); if(area != nullptr) { this->_xSpinbox->setValue(0); + this->_xSpinbox->setMinimum(0); + this->_xSpinbox->setMaximum(area->image().width()); + this->_ySpinbox->setValue(0); + this->_ySpinbox->setMinimum(0); + this->_xSpinbox->setMaximum(area->image().height()); + this->_widthSpinbox->setValue(area->image().width()); + this->_widthSpinbox->setMinimum(0); + this->_widthSpinbox->setMaximum(area->image().width()); + this->_heightSpinbox->setValue(area->image().height()); + this->_heightSpinbox->setMinimum(0); + this->_heightSpinbox->setMaximum(area->image().height()); this->show(); } } diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index 3fa5137..6b61a5b 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -69,7 +69,6 @@ MainWindow::MainWindow(QWidget * parent) this->_multyImageModifier = new ui::MultyImageModifier(this->_viewManager, this->_emitDrawCheckbox, this->_receiveDrawCheckbox, this->_samplingDrawList); this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Ignore())); - this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Clamp())); this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Average())); qDebug() << "mark_5"; diff --git a/IHM_Retouche_Photo/tools/editable/bucket.cpp b/IHM_Retouche_Photo/tools/editable/bucket.cpp index 6b497c2..e6ef977 100644 --- a/IHM_Retouche_Photo/tools/editable/bucket.cpp +++ b/IHM_Retouche_Photo/tools/editable/bucket.cpp @@ -2,7 +2,7 @@ namespace tool { Bucket::Bucket(const ColorPickerWidget & cp) - : Editable(cp, "Pot de painture", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png")) {} + : Editable(cp, "Pot de peinture", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png")) {} void Bucket::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &) {} diff --git a/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp b/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp index 5bc5d3e..f744d4e 100644 --- a/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp @@ -2,7 +2,7 @@ namespace tool { Ellipse::Ellipse(const ColorPickerWidget & cp) - : Selectionable(cp, "Elipse", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-ellipse.png"), true), _clicked(0,0), _hold(false), _multy(false) { + : Selectionable(cp, "Ellipse", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-ellipse.png"), true), _clicked(0,0), _hold(false), _multy(false) { } diff --git a/IHM_Retouche_Photo/ui/menu/imagemenulambda.cpp b/IHM_Retouche_Photo/ui/menu/imagemenulambda.cpp index feaa71f..85d8171 100644 --- a/IHM_Retouche_Photo/ui/menu/imagemenulambda.cpp +++ b/IHM_Retouche_Photo/ui/menu/imagemenulambda.cpp @@ -1,16 +1,16 @@ #include "imagemenulambda.h" namespace ui { - imagemenulambda::imagemenulambda(dialog::ReScaleDialog * rescale, dialog::ReSizeDialog * resize,ViewManager * manager) + ImageMenuLambda::ImageMenuLambda(dialog::ReScaleDialog * rescale, dialog::ReSizeDialog * resize,ViewManager * manager) : _menu(nullptr), _rescale(rescale), _resize(resize), _viewManager(manager), _area(nullptr) { QObject::connect(this->_viewManager, SIGNAL(changedView(ImageArea*)), this, SLOT(viewChange(ImageArea*))); } - void imagemenulambda::initializeMenu(const QMenu * menu) { + void ImageMenuLambda::initializeMenu(const QMenu * menu) { this->_menu = menu; } - void imagemenulambda::viewChange(ImageArea * area) { + void ImageMenuLambda::viewChange(ImageArea * area) { if(this->_menu != nullptr) { if(this->_area != nullptr) { QObject::disconnect(this->_menu->actions().at(Actions::RESIZE), SIGNAL(triggered()), this->_resize, SLOT(use())); @@ -34,7 +34,7 @@ namespace ui { } } - void imagemenulambda::turn_H() { + void ImageMenuLambda::turn_H() { if(this->_area != nullptr) { QTransform t; t.rotate(180, Qt::XAxis); @@ -42,7 +42,7 @@ namespace ui { } } - void imagemenulambda::turn_V() { + void ImageMenuLambda::turn_V() { if(this->_area != nullptr) { QTransform t; t.rotate(180, Qt::YAxis); @@ -50,7 +50,7 @@ namespace ui { } } - void imagemenulambda::turn_left() { + void ImageMenuLambda::turn_left() { if(this->_area != nullptr) { QTransform t; t.rotate(-90); @@ -58,7 +58,7 @@ namespace ui { } } - void imagemenulambda::turn_right() { + void ImageMenuLambda::turn_right() { if(this->_area != nullptr) { QTransform t; t.rotate(90); diff --git a/IHM_Retouche_Photo/ui/menu/imagemenulambda.h b/IHM_Retouche_Photo/ui/menu/imagemenulambda.h index 721534a..0463721 100644 --- a/IHM_Retouche_Photo/ui/menu/imagemenulambda.h +++ b/IHM_Retouche_Photo/ui/menu/imagemenulambda.h @@ -9,7 +9,7 @@ #include "../view/viewmanager.h" namespace ui { - class imagemenulambda : public MenuLambda { + class ImageMenuLambda : public MenuLambda { Q_OBJECT private: const QMenu * _menu; @@ -27,7 +27,7 @@ namespace ui { }; public: - imagemenulambda(dialog::ReScaleDialog *, dialog::ReSizeDialog *,ViewManager *); + ImageMenuLambda(dialog::ReScaleDialog *, dialog::ReSizeDialog *,ViewManager *); virtual void initializeMenu(const QMenu *) final; diff --git a/IHM_Retouche_Photo/ui/view/imagearea.cpp b/IHM_Retouche_Photo/ui/view/imagearea.cpp index fd92745..ac91ad3 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.cpp +++ b/IHM_Retouche_Photo/ui/view/imagearea.cpp @@ -226,18 +226,20 @@ namespace ui { void ImageArea::setSize(const QPoint & anchor, const QPoint & cliping) { QImage copy = this->_image; - QPoint size(cliping.x() > copy.width() ? copy.width() : cliping.x(), cliping.y() > copy.height() ? copy.height() : cliping.y()); - - this->_image = QImage(size.x(), size.y(), QImage::Format_RGB32); - - int i = 0, j = 0; - for(int x = 0; x < size.x(); x++) { - for(int y = 0; y < size.y(); y++) { - this->setColor(QPoint(i, j), copy.pixelColor(anchor.x() + x, anchor.y() + y)); - j++; + this->_image = QImage(cliping.x(), cliping.y(), QImage::Format_RGB32); + if(anchor.x() + cliping.x() < this->_image.width() && anchor.y() + cliping.y() < this->_image.height()) { + int i = 0, j = 0; + for(int x = 0; x <= cliping.x(); x++) { + for(int y = 0; y <= cliping.x(); y++) { + this->setColor(QPoint(i, j), copy.pixelColor(anchor.x() + x, anchor.y() + y)); + j++; + } + i++; + j = 0; } - i++; - j = 0; + } + else { + QMessageBox::critical(this, "Erreur de rognage", "Valeurs pour le rognage invalide."); } } -- GitLab