mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-17 22:00:29 +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);
|
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
// Used to draw on the widget
|
// Used to draw on the widget
|
||||||
QPainter painter(&imageData);
|
QPainter* painter = new QPainter(&imageData);
|
||||||
|
|
||||||
// Set the current settings for the pen
|
// 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
|
// Draw a line from the last registered point to the current
|
||||||
painter.drawPoint(p1);
|
painter->drawPoint(p1);
|
||||||
|
delete painter;
|
||||||
|
painter = nullptr;
|
||||||
|
|
||||||
if(fastRenderering){
|
if(fastRenderering){
|
||||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
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);
|
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
// Used to draw on the widget
|
// Used to draw on the widget
|
||||||
QPainter painter(&imageData);
|
QPainter* painter = new QPainter(&imageData);
|
||||||
|
|
||||||
// Set the current settings for the pen
|
// 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
|
// Draw a line from the last registered point to the current
|
||||||
painter.drawPoint(p1);
|
painter->drawPoint(p1);
|
||||||
|
delete painter;
|
||||||
|
|
||||||
|
painter = nullptr;
|
||||||
if(fastRenderering){
|
if(fastRenderering){
|
||||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
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);
|
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
// Used to draw on the widget
|
// Used to draw on the widget
|
||||||
QPainter painter(&imageData);
|
QPainter* painter = new QPainter(&imageData);
|
||||||
|
|
||||||
// Set the current settings for the pen
|
// 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
|
// 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){
|
if(fastRenderering){
|
||||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
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){
|
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);
|
this->layerBundle.erase(layerBundle.begin()+idx);
|
||||||
if(activeLayer>=idx) {
|
if(activeLayer>=idx) {
|
||||||
activeLayer--;
|
activeLayer--;
|
||||||
@@ -93,9 +93,11 @@ void PaintingArea::setLayerActive(int idx){
|
|||||||
|
|
||||||
void PaintingArea::setLayerAlpha(int idx, int alpha){
|
void PaintingArea::setLayerAlpha(int idx, int alpha){
|
||||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||||
|
if(alpha>=0 && alpha<=255) {
|
||||||
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
|
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Used to load the image and place it in the widget
|
// Used to load the image and place it in the widget
|
||||||
bool PaintingArea::open(const QString &filePath){
|
bool PaintingArea::open(const QString &filePath){
|
||||||
@@ -138,6 +140,12 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
|
|||||||
if(this->activeLayer==-1) {
|
if(this->activeLayer==-1) {
|
||||||
return;
|
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;
|
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
|
||||||
active->drawPlain(QColor(r, g, b, a));
|
active->drawPlain(QColor(r, g, b, a));
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
void movePositionActive(int x, int y);
|
void movePositionActive(int x, int y);
|
||||||
/*!
|
/*!
|
||||||
* \brief The moveActiveLayer moves the active layer to a specific position in the layer stack
|
* \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);
|
void moveActiveLayer(int idx);
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
|
|||||||
|
|
||||||
QColor oldColor = this->activeLayer->image->getPixelColor(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);
|
Canvas->image->drawPixel(start,newColor);
|
||||||
|
|
||||||
QPoint left, right, top, down;
|
QPoint left, right, top, down;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user