diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index 5e5e62d..9c65bd5 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -41,7 +41,9 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){ QPainter painter(&newImage); painter.drawImage(QPoint(0, 0), *image); *image = newImage; - updateRendererSetting(fastRenderer); + if(fastRenderer){ + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){ @@ -56,7 +58,9 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){ // Draw a line from the last registered point to the current painter.drawPoint(p1); - updateRendererSetting(fastRenderer); + if(fastRenderer){ + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){ @@ -70,7 +74,9 @@ void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& p 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); - updateRendererSetting(fastRenderer); + if(fastRenderer){ + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){ @@ -85,7 +91,9 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co // Draw a line from the last registered point to the current painter.drawLine(p1, p2); - updateRendererSetting(fastRenderer); + if(fastRenderer){ + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawPlain(const QColor& color){ @@ -93,11 +101,17 @@ void IntelliImage::drawPlain(const QColor& color){ this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); } imageData.fill(color); - updateRendererSetting(fastRenderer); + if(fastRenderer){ + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } QColor IntelliImage::getPixelColor(QPoint& point){ - return imageData.pixelColor(point); + if(fastRenderer){ + QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32); + return copy.pixelColor(point); + } + return imageData.pixelColor(point); } void IntelliImage::updateRendererSetting(bool fastRendererOn){ diff --git a/src/IntelliHelper/IntelliRenderSettings.h b/src/IntelliHelper/IntelliRenderSettings.h index b7ee8a0..5763bb0 100644 --- a/src/IntelliHelper/IntelliRenderSettings.h +++ b/src/IntelliHelper/IntelliRenderSettings.h @@ -14,7 +14,7 @@ public: bool getFastRenderer(); private: - bool fastRenderer = false; + bool fastRenderer = true; }; #endif // INTELLIRENDERSETTINGS_H diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index f859001..e5a8a19 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -147,21 +147,25 @@ void PaintingArea::floodFill(int r, int g, int b, int a){ } void PaintingArea::movePositionActive(int x, int y){ - if(Tool->getIsDrawing()){ - IntelliTool* temp = copyActiveTool(); - delete this->Tool; - this->Tool = temp; + if(Tool!=nullptr){ + if(Tool->getIsDrawing()){ + IntelliTool* temp = copyActiveTool(); + delete this->Tool; + this->Tool = temp; + } } layerBundle[static_cast(activeLayer)].widthOffset += x; layerBundle[static_cast(activeLayer)].heightOffset += y; } void PaintingArea::moveActiveLayer(int idx){ - if(Tool->getIsDrawing()){ - IntelliTool* temp = copyActiveTool(); - delete this->Tool; - this->Tool = temp; - } + if(Tool!=nullptr){ + if(Tool->getIsDrawing()){ + IntelliTool* temp = copyActiveTool(); + delete this->Tool; + this->Tool = temp; + } + } if(idx==1) { this->selectLayerUp(); }else if(idx==-1) { @@ -170,11 +174,13 @@ void PaintingArea::moveActiveLayer(int idx){ } void PaintingArea::slotActivateLayer(int a){ + if(Tool!=nullptr){ if(Tool->getIsDrawing()){ IntelliTool* temp = copyActiveTool(); delete this->Tool; this->Tool = temp; } + } if(a>=0 && a < static_cast(layerBundle.size())) { this->setLayerActive(a); } diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 43d0c31..88d2e07 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -57,7 +57,7 @@ void IntelliTool::mergeToolLayer(){ QColor clr_0; QColor clr_1; if(Area->renderSettings.getFastRenderer()){ - activeLayer->image->imageData.convertToFormat(QImage::Format_ARGB32); + activeLayer->image->imageData = activeLayer->image->imageData.convertToFormat(QImage::Format_ARGB32); } for(int y=0; yheight; y++) { for(int x=0; xwidth; x++) { @@ -77,7 +77,7 @@ void IntelliTool::mergeToolLayer(){ } } if(Area->renderSettings.getFastRenderer()){ - activeLayer->image->imageData.convertToFormat(QImage::Format_Indexed8); + activeLayer->image->imageData = activeLayer->image->imageData.convertToFormat(QImage::Format_Indexed8); } }