mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Merge branch 'dev-tools-seb' into dev-docs
This commit is contained in:
@@ -78,6 +78,6 @@ void IntelliImage::drawPlain(const QColor& color){
|
||||
imageData.fill(color);
|
||||
}
|
||||
|
||||
QColor IntelliImage::getPixelColor(int x, int y){
|
||||
return imageData.pixelColor(x,y);
|
||||
QColor IntelliImage::getPixelColor(QPoint& point){
|
||||
return imageData.pixelColor(point);
|
||||
}
|
||||
|
||||
@@ -121,11 +121,10 @@ public:
|
||||
|
||||
/*!
|
||||
* \brief A function that returns the pixelcolor at a certain point
|
||||
* \param x - The x-coordinate of the point.
|
||||
* \param y - The y-coordintae of the point.
|
||||
* \param point - The point from whcih to get the coordinates.
|
||||
* \return The color of the Pixel as QColor.
|
||||
*/
|
||||
virtual QColor getPixelColor(int x, int y);
|
||||
virtual QColor getPixelColor(QPoint& point);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
#include "Tool/IntelliToolLine.h"
|
||||
#include "Tool/IntelliToolCircle.h"
|
||||
#include "Tool/IntelliToolRectangle.h"
|
||||
#include "Tool/IntelliToolFloodFill.h"
|
||||
|
||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||
:QWidget(parent){
|
||||
//test yout tool here and reset after accomplished test
|
||||
this->Tool = new IntelliToolRectangle(this, &colorPicker);
|
||||
this->Tool = new IntelliToolFloodFill(this, &colorPicker);
|
||||
this->setUp(maxWidth, maxHeight);
|
||||
//tetsing
|
||||
this->addLayer(200,200,0,0,ImageType::Shaped_Image);
|
||||
|
||||
77
src/Tool/IntelliToolFloodFill.cpp
Normal file
77
src/Tool/IntelliToolFloodFill.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "IntelliToolFloodFill.h"
|
||||
#include "Layer/PaintingArea.h"
|
||||
#include "QColorDialog"
|
||||
#include "QInputDialog"
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
|
||||
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
}
|
||||
|
||||
IntelliToolFloodFill::~IntelliToolFloodFill(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IntelliToolFloodFill::onMouseRightPressed(int x, int y){
|
||||
IntelliTool::onMouseRightPressed(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolFloodFill::onMouseRightReleased(int x, int y){
|
||||
IntelliTool::onMouseRightReleased(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
|
||||
QPoint start(x,y);
|
||||
std::queue<QPoint> Q;
|
||||
Q.push(start);
|
||||
|
||||
QColor oldColor = this->Active->image->getPixelColor(start);
|
||||
QColor newColor = this->colorPicker->getFirstColor();
|
||||
Canvas->image->drawPixel(start,newColor);
|
||||
|
||||
QPoint left, right, top, down;
|
||||
while(!Q.empty()){
|
||||
QPoint Current = Q.front();
|
||||
Q.pop();
|
||||
|
||||
left = QPoint(Current.x()-1,Current.y() );
|
||||
right = QPoint(Current.x()+1,Current.y() );
|
||||
top = QPoint(Current.x() ,Current.y()-1);
|
||||
down = QPoint(Current.x() ,Current.y()+1);
|
||||
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (Active->image->getPixelColor(right) == oldColor)){
|
||||
Canvas->image->drawPixel(right,newColor);
|
||||
Q.push(right);
|
||||
}
|
||||
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (Active->image->getPixelColor(left) == oldColor)){
|
||||
Canvas->image->drawPixel(left,newColor);
|
||||
Q.push(left);
|
||||
}
|
||||
if((top.y() < Canvas->hight) && (Canvas->image->getPixelColor(top) != newColor) && (Active->image->getPixelColor(top) == oldColor)){
|
||||
Canvas->image->drawPixel(top,newColor);
|
||||
Q.push(top);
|
||||
}
|
||||
if((down.y() >= 0) && (Canvas->image->getPixelColor(down) != newColor) && (Active->image->getPixelColor(down) == oldColor)){
|
||||
Canvas->image->drawPixel(down,newColor);
|
||||
Q.push(down);
|
||||
}
|
||||
}
|
||||
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliToolFloodFill::onMouseLeftReleased(int x, int y){
|
||||
IntelliTool::onMouseLeftReleased(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolFloodFill::onWheelScrolled(int value){
|
||||
IntelliTool::onWheelScrolled(value);
|
||||
|
||||
}
|
||||
|
||||
void IntelliToolFloodFill::onMouseMoved(int x, int y){
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
Reference in New Issue
Block a user