mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
nearly all tests but without benchmark
This commit is contained in:
@@ -59,13 +59,16 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
QPainter* painter = new QPainter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter->setPen(QPen(color, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
painter->drawPoint(p1);
|
||||
delete painter;
|
||||
painter = nullptr;
|
||||
|
||||
if(fastRenderering){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
@@ -76,12 +79,15 @@ void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& p
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
QPainter* painter = new QPainter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter->setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
painter->drawPoint(p1);
|
||||
delete painter;
|
||||
|
||||
painter = nullptr;
|
||||
if(fastRenderering){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
@@ -92,13 +98,16 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
QPainter* painter = new QPainter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
painter->setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawLine(p1, p2);
|
||||
painter->drawLine(p1, p2);
|
||||
delete painter;
|
||||
painter = nullptr;
|
||||
|
||||
if(fastRenderering){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
|
||||
|
||||
|
||||
void PaintingArea::deleteLayer(int idx){
|
||||
if(idx<static_cast<int>(layerBundle.size())) {
|
||||
if(idx < static_cast<int>(layerBundle.size())&&idx>=0) {
|
||||
this->layerBundle.erase(layerBundle.begin()+idx);
|
||||
if(activeLayer>=idx) {
|
||||
activeLayer--;
|
||||
@@ -93,7 +93,9 @@ void PaintingArea::setLayerActive(int idx){
|
||||
|
||||
void PaintingArea::setLayerAlpha(int idx, int alpha){
|
||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
|
||||
if(alpha>=0 && alpha<=255) {
|
||||
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +140,12 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
|
||||
if(this->activeLayer==-1) {
|
||||
return;
|
||||
}
|
||||
if(r >255 || g>255|| b>255 || a>255){
|
||||
return;
|
||||
}
|
||||
if(r < 0 || g < 0|| b < 0 || a < 0){
|
||||
return;
|
||||
}
|
||||
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
|
||||
active->drawPlain(QColor(r, g, b, a));
|
||||
update();
|
||||
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
void movePositionActive(int x, int y);
|
||||
/*!
|
||||
* \brief The moveActiveLayer moves the active layer to a specific position in the layer stack
|
||||
* \param idx - The index of the new position the layer should be in
|
||||
* \param idx - The direction the layer should move
|
||||
*/
|
||||
void moveActiveLayer(int idx);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void IntelliToolFloodFill::onMouseRightReleased(int x, int y){
|
||||
void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
|
||||
if(!(x>=0 && x<Area->getWidthOfActive() && y>=0 && y<Area->getHeightOfActive())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
|
||||
QPoint start(x,y);
|
||||
@@ -33,7 +33,10 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
|
||||
Q.push(start);
|
||||
|
||||
QColor oldColor = this->activeLayer->image->getPixelColor(start);
|
||||
QColor newColor = this->colorPicker->getFirstColor();
|
||||
QColor newColor = this->colorPicker->getFirstColor();
|
||||
if(newColor == oldColor){
|
||||
return;
|
||||
}
|
||||
Canvas->image->drawPixel(start,newColor);
|
||||
|
||||
QPoint left, right, top, down;
|
||||
@@ -45,20 +48,20 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int 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) && (activeLayer->image->getPixelColor(right) == oldColor)) {
|
||||
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (activeLayer->image->getPixelColor(right) == oldColor)) {
|
||||
Canvas->image->drawPixel(right,newColor);
|
||||
Q.push(right);
|
||||
}
|
||||
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (activeLayer->image->getPixelColor(left) == oldColor)) {
|
||||
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (activeLayer->image->getPixelColor(left) == oldColor)) {
|
||||
Canvas->image->drawPixel(left,newColor);
|
||||
Q.push(left);
|
||||
}
|
||||
if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (activeLayer->image->getPixelColor(top) == oldColor)) {
|
||||
if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (activeLayer->image->getPixelColor(top) == oldColor)) {
|
||||
Canvas->image->drawPixel(top,newColor);
|
||||
Q.push(top);
|
||||
}
|
||||
if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (activeLayer->image->getPixelColor(down) == oldColor)) {
|
||||
Canvas->image->drawPixel(down,newColor);
|
||||
if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (activeLayer->image->getPixelColor(down) == oldColor)) {
|
||||
Canvas->image->drawPixel(down,newColor);
|
||||
Q.push(down);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user