This commit is contained in:
AshBastian
2020-01-09 00:58:03 +01:00
parent 8b1fd5c3f0
commit 46a69024d3
15 changed files with 111 additions and 208 deletions

View File

@@ -8,5 +8,6 @@
<file>icons/pen-tool.svg</file> <file>icons/pen-tool.svg</file>
<file>icons/polygon-tool.svg</file> <file>icons/polygon-tool.svg</file>
<file>icons/rectangle-tool.svg</file> <file>icons/rectangle-tool.svg</file>
<file>icons/Wechselpfeile.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -97,8 +97,11 @@ void IntelliPhotoGui::slotDeleteLayer(){
tr("Number:"), tr("Number:"),
1,0, 500, 1, &ok); 1,0, 500, 1, &ok);
// Create New Layer // Create New Layer
if (ok) if (ok){
paintingArea->deleteLayer(layerNumber); paintingArea->deleteLayer(layerNumber);
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
}
} }
void IntelliPhotoGui::slotSetActiveAlpha(){ void IntelliPhotoGui::slotSetActiveAlpha(){
@@ -192,19 +195,29 @@ void IntelliPhotoGui::slotSetActiveLayer(){
if (ok1) if (ok1)
{ {
paintingArea->setLayerActive(layer); paintingArea->setLayerActive(layer);
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
} }
} }
void IntelliPhotoGui::slotSetFirstColor(){ void IntelliPhotoGui::slotSetFirstColor(){
paintingArea->colorPickerSetFirstColor(); paintingArea->colorPickerSetFirstColor();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotSetSecondColor(){ void IntelliPhotoGui::slotSetSecondColor(){
paintingArea->colorPickerSetSecondColor(); paintingArea->colorPickerSetSecondColor();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotSwapColor(){ void IntelliPhotoGui::slotSwapColor(){
paintingArea->colorPickerSwapColors(); paintingArea->colorPickerSwapColors();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotCreatePenTool(){ void IntelliPhotoGui::slotCreatePenTool(){
@@ -351,13 +364,16 @@ void IntelliPhotoGui::createActions(){
//Create Color Actions here //Create Color Actions here
actionColorPickerFirstColor = new QAction(tr("&Main"), this); actionColorPickerFirstColor = new QAction(tr("&Main"), this);
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor())); connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
connect(FirstColorButton, SIGNAL(clicked()), this, SLOT(slotSetFirstColor()));
actionColorPickerSecondColor = new QAction(tr("&Secondary"), this); actionColorPickerSecondColor = new QAction(tr("&Secondary"), this);
connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor())); connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor()));
connect(SecondColorButton, SIGNAL(clicked()), this, SLOT(slotSetSecondColor()));
actionColorSwap = new QAction(tr("&Switch"), this); actionColorSwap = new QAction(tr("&Switch"), this);
actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor())); connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor()));
connect(SwitchColorButton, SIGNAL(clicked()), this, SLOT(slotSwapColor()));
//Create Tool actions down here //Create Tool actions down here
actionCreatePlainTool = new QAction(tr("&Plain"), this); actionCreatePlainTool = new QAction(tr("&Plain"), this);
@@ -547,10 +563,10 @@ void IntelliPhotoGui::createGui(){
WidthLine = new QLabel(); WidthLine = new QLabel();
WidthLine->setText("Width"); WidthLine->setText("Width");
WidthLine->setFixedSize(QSize(55,20)); WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth = new QLineEdit(); EditLineWidth = new QLineEdit();
EditLineWidth->setFixedSize(QSize(50,20)); EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth->setText("5"); EditLineWidth->setText("5");
ValidatorLineWidth = new QIntValidator(); ValidatorLineWidth = new QIntValidator();
ValidatorLineWidth->setTop(99); ValidatorLineWidth->setTop(99);
@@ -559,46 +575,64 @@ void IntelliPhotoGui::createGui(){
innerAlphaLine = new QLabel(); innerAlphaLine = new QLabel();
innerAlphaLine->setText("Inner Alpha"); innerAlphaLine->setText("Inner Alpha");
innerAlphaLine->setFixedSize(QSize(55,20)); innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha = new QLineEdit(); EditLineInnerAlpha = new QLineEdit();
EditLineInnerAlpha->setFixedSize(QSize(50,20)); EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha->setText("255"); EditLineInnerAlpha->setText("255");
ValidatorInnerAlpha = new QIntValidator(); ValidatorInnerAlpha = new QIntValidator();
ValidatorInnerAlpha->setTop(999); ValidatorInnerAlpha->setTop(999);
ValidatorInnerAlpha->setBottom(0); ValidatorInnerAlpha->setBottom(0);
EditLineInnerAlpha->setValidator(ValidatorInnerAlpha); EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
Farbe1 = new QLabel(); FirstColorButton = new QPushButton();
Farbe1->setText(""); FirstColorButton->setFixedSize(Buttonsize/2);
QPalette Palette;
Palette.setColor(QPalette::Background,QColor(0,0,0));//paintingArea->colorPicker.getFirstColor()); SecondColorButton = new QPushButton();
Farbe1->setPalette(Palette); SecondColorButton->setFixedSize(Buttonsize/2);
Farbe1->setFixedSize(QSize(20,20));
p = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
SwitchColorButton = new QPushButton();
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2);
SwitchColorButton->setIcon(p);
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2));
ActiveLayerLine = new QLabel();
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
// set gui elements // set gui elements
mainLayout->addWidget(paintingArea,1,1,20,1); mainLayout->addWidget(paintingArea,1,1,20,1);
mainLayout->addWidget(CircleButton,1,2,1,1); mainLayout->addWidget(CircleButton,1,2,1,2);
mainLayout->addWidget(FloodFillButton,2,2,1,1); mainLayout->addWidget(FloodFillButton,2,2,1,2);
mainLayout->addWidget(LineButton,3,2,1,1); mainLayout->addWidget(LineButton,3,2,1,2);
mainLayout->addWidget(PenButton,4,2,1,1); mainLayout->addWidget(PenButton,4,2,1,2);
mainLayout->addWidget(PlainButton,5,2,1,1); mainLayout->addWidget(PlainButton,5,2,1,2);
mainLayout->addWidget(PolygonButton,6,2,1,1); mainLayout->addWidget(PolygonButton,6,2,1,2);
mainLayout->addWidget(RectangleButton,7,2,1,1); mainLayout->addWidget(RectangleButton,7,2,1,2);
mainLayout->addWidget(WidthLine,8,2,1,1); mainLayout->addWidget(WidthLine,8,2,1,2);
mainLayout->addWidget(EditLineWidth,9,2,1,1); mainLayout->addWidget(EditLineWidth,9,2,1,2);
mainLayout->addWidget(innerAlphaLine,10,2,1,1); mainLayout->addWidget(innerAlphaLine,10,2,1,2);
mainLayout->addWidget(EditLineInnerAlpha,11,2,1,1); mainLayout->addWidget(EditLineInnerAlpha,11,2,1,2);
mainLayout->addWidget(Farbe1,12,2,1,1); mainLayout->addWidget(FirstColorButton,12,2,1,1);
mainLayout->addWidget(SecondColorButton,12,3,1,1);
mainLayout->addWidget(SwitchColorButton,13,2,1,2);
mainLayout->addWidget(ActiveLayerLine,14,2,1,2);
} }
void IntelliPhotoGui::setIntelliStyle(){ void IntelliPhotoGui::setIntelliStyle(){
// Set the title // Set the title
setWindowTitle("IntelliPhoto Prototype"); setWindowTitle("IntelliPhoto Prototype");
// Set style sheet // Set style sheet
this->setStyleSheet("background-color:rgb(64,64,64)"); this->setStyleSheet("background-color:rgb(64,64,64)");
this->centralGuiWidget->setStyleSheet("color:rgb(255,255,255)"); this->centralGuiWidget->setStyleSheet("color:rgb(255,255,255)");
this->menuBar()->setStyleSheet("color:rgb(255,255,255)"); this->menuBar()->setStyleSheet("color:rgb(255,255,255)");
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
} }
bool IntelliPhotoGui::maybeSave(){ bool IntelliPhotoGui::maybeSave(){

View File

@@ -94,7 +94,7 @@ void setDefaultToolValue();
// What we'll draw on // What we'll draw on
PaintingArea* paintingArea; PaintingArea* paintingArea;
const QSize Buttonsize = QSize(50,50); const QSize Buttonsize = QSize(70,70);
QPixmap p; QPixmap p;
QPushButton* CircleButton; QPushButton* CircleButton;
QPushButton* FloodFillButton; QPushButton* FloodFillButton;
@@ -110,7 +110,11 @@ QLineEdit* EditLineInnerAlpha;
QIntValidator* ValidatorLineWidth; QIntValidator* ValidatorLineWidth;
QIntValidator* ValidatorInnerAlpha; QIntValidator* ValidatorInnerAlpha;
QLabel* Farbe1; QPushButton* FirstColorButton;
QPushButton* SecondColorButton;
QPushButton* SwitchColorButton;
QLabel* ActiveLayerLine;
// The menu widgets // The menu widgets
QMenu*saveAsMenu; QMenu*saveAsMenu;

View File

@@ -2,16 +2,9 @@
#include <QSize> #include <QSize>
#include <QPainter> #include <QPainter>
IntelliImage::IntelliImage(int width, int height, bool fastRendererOn) IntelliImage::IntelliImage(int weight, int height)
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){ : imageData(QSize(weight, height), QImage::Format_ARGB32){
if(fastRendererOn){ imageData.fill(QColor(255,255,255,255));
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
}
imageData.fill(QColor(255,255,255,255));
if(fastRendererOn){
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
}
this->fastRenderer = fastRendererOn;
} }
@@ -30,7 +23,7 @@ bool IntelliImage::loadImage(const QString &filePath){
// scaled Image to size of Layer // scaled Image to size of Layer
loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio);
imageData = loadedImage.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32); imageData = loadedImage.convertToFormat(QImage::Format_ARGB32);
return true; return true;
} }
@@ -40,23 +33,17 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
return; return;
// Create a new image to display and fill it with white // Create a new image to display and fill it with white
QImage newImage(newSize, QImage::Format_ARGB32); QImage newImage(newSize, QImage::Format_ARGB32);
newImage.fill(qRgb(255, 255, 255)); newImage.fill(qRgb(255, 255, 255));
// Draw the image // Draw the image
QPainter painter(&newImage); QPainter painter(&newImage);
painter.drawImage(QPoint(0, 0), *image); painter.drawImage(QPoint(0, 0), *image);
*image = newImage; *image = newImage;
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
if(fastRenderer){ // Used to draw on the widget
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
QPainter painter(&imageData); QPainter painter(&imageData);
// Set the current settings for the pen // Set the current settings for the pen
@@ -64,32 +51,20 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
// 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);
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){ void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){
if(fastRenderer){ // Used to draw on the widget
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
QPainter painter(&imageData); QPainter painter(&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);
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){ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){
if(fastRenderer){ // Used to draw on the widget
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
// Used to draw on the widget
QPainter painter(&imageData); QPainter painter(&imageData);
// Set the current settings for the pen // Set the current settings for the pen
@@ -97,30 +72,12 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
// 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);
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
void IntelliImage::drawPlain(const QColor& color){ void IntelliImage::drawPlain(const QColor& color){
if(fastRenderer){ imageData.fill(color);
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
}
imageData.fill(color);
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
QColor IntelliImage::getPixelColor(QPoint& point){ QColor IntelliImage::getPixelColor(QPoint& point){
if(fastRenderer){ return imageData.pixelColor(point);
QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32);
return copy.pixelColor(point);
}
return imageData.pixelColor(point);
}
void IntelliImage::updateRendererSetting(bool fastRendererOn){
this->fastRenderer = fastRendererOn;
this->imageData = this->imageData.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
} }

View File

@@ -8,7 +8,6 @@
#include <QWidget> #include <QWidget>
#include <vector> #include <vector>
#include "IntelliHelper/IntelliRenderSettings.h"
#include "IntelliHelper/IntelliTriangulation.h" #include "IntelliHelper/IntelliTriangulation.h"
class IntelliTool; class IntelliTool;
@@ -40,20 +39,13 @@ QImage imageData;
* \brief The Type, an Image is. * \brief The Type, an Image is.
*/ */
ImageType TypeOfImage; ImageType TypeOfImage;
/*!
* \brief fastRenderer is the flag that represents the usage of 8bit pictures.
*/
bool fastRenderer;
public: public:
/*! /*!
* \brief The Construcor of the IntelliImage. Given the Image dimensions. * \brief The Construcor of the IntelliImage. Given the Image dimensions.
* \param width - The width of the Image. * \param width - The width of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
*/ */
IntelliImage(int width, int height, bool fastRendererOn); IntelliImage(int width, int height);
/*! /*!
* \brief An Abstract Destructor. * \brief An Abstract Destructor.
@@ -148,13 +140,6 @@ virtual bool loadImage(const QString &filePath);
* \return The color of the Pixel as QColor. * \return The color of the Pixel as QColor.
*/ */
virtual QColor getPixelColor(QPoint& point); virtual QColor getPixelColor(QPoint& point);
/*!
* \brief updateRendererSetting updates the existing image format to the new format.
* \param fastRendererOn flag for the 8bit image handeling.
*/
virtual void updateRendererSetting(bool fastRendererOn);
}; };
#endif #endif

View File

@@ -3,10 +3,9 @@
#include <QRect> #include <QRect>
#include <QDebug> #include <QDebug>
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) IntelliRasterImage::IntelliRasterImage(int weight, int height)
: IntelliImage(width, height, fastRendererOn){ : IntelliImage(weight, height){
TypeOfImage = IntelliImage::ImageType::Raster_Image; TypeOfImage = IntelliImage::ImageType::Raster_Image;
this->fastRenderer = fastRendererOn;
} }
IntelliRasterImage::~IntelliRasterImage(){ IntelliRasterImage::~IntelliRasterImage(){
@@ -14,7 +13,7 @@ IntelliRasterImage::~IntelliRasterImage(){
} }
IntelliImage* IntelliRasterImage::getDeepCopy(){ IntelliImage* IntelliRasterImage::getDeepCopy(){
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false); IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height());
raster->imageData.fill(Qt::transparent); raster->imageData.fill(Qt::transparent);
raster->TypeOfImage = IntelliImage::ImageType::Raster_Image; raster->TypeOfImage = IntelliImage::ImageType::Raster_Image;
return raster; return raster;
@@ -30,9 +29,6 @@ QImage IntelliRasterImage::getDisplayable(int alpha){
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData; QImage copy = imageData;
if(fastRenderer){
copy = copy.convertToFormat(QImage::Format_ARGB32);
}
for(int y = 0; y<copy.height(); y++) { for(int y = 0; y<copy.height(); y++) {
for(int x = 0; x<copy.width(); x++) { for(int x = 0; x<copy.width(); x++) {
QColor clr = copy.pixelColor(x,y); QColor clr = copy.pixelColor(x,y);
@@ -40,9 +36,6 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
copy.setPixelColor(x,y, clr); copy.setPixelColor(x,y, clr);
} }
} }
if(fastRenderer){
copy = copy.convertToFormat(QImage::Format_Indexed8);
}
return copy.scaled(displaySize,Qt::IgnoreAspectRatio); return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
} }

View File

@@ -18,9 +18,8 @@ public:
* \brief The Construcor of the IntelliRasterImage. Given the Image dimensions. * \brief The Construcor of the IntelliRasterImage. Given the Image dimensions.
* \param width - The width of the Image. * \param width - The width of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
*/ */
IntelliRasterImage(int width, int height, bool fastRendererOn); IntelliRasterImage(int width, int height);
/*! /*!
* \brief An Destructor. * \brief An Destructor.

View File

@@ -4,10 +4,9 @@
#include <QRect> #include <QRect>
#include <QDebug> #include <QDebug>
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) IntelliShapedImage::IntelliShapedImage(int weight, int height)
: IntelliRasterImage(width, height, fastRendererOn){ : IntelliRasterImage(weight, height){
TypeOfImage = IntelliImage::ImageType::Shaped_Image; TypeOfImage = IntelliImage::ImageType::Shaped_Image;
this->fastRenderer = fastRendererOn;
} }
IntelliShapedImage::~IntelliShapedImage(){ IntelliShapedImage::~IntelliShapedImage(){
@@ -19,7 +18,7 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
} }
IntelliImage* IntelliShapedImage::getDeepCopy(){ IntelliImage* IntelliShapedImage::getDeepCopy(){
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false); IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height());
shaped->setPolygon(this->polygonData); shaped->setPolygon(this->polygonData);
shaped->imageData.fill(Qt::transparent); shaped->imageData.fill(Qt::transparent);
shaped->TypeOfImage = IntelliImage::ImageType::Shaped_Image; shaped->TypeOfImage = IntelliImage::ImageType::Shaped_Image;
@@ -27,11 +26,7 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
} }
void IntelliShapedImage::calculateVisiblity(){ void IntelliShapedImage::calculateVisiblity(){
if(fastRenderer){ if(polygonData.size()<=2) {
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
}
if(polygonData.size()<=2) {
QColor clr; QColor clr;
for(int y=0; y<imageData.height(); y++) { for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++) { for(int x=0; x<imageData.width(); x++) {
@@ -40,9 +35,6 @@ void IntelliShapedImage::calculateVisiblity(){
imageData.setPixelColor(x,y,clr); imageData.setPixelColor(x,y,clr);
} }
} }
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
return; return;
} }
QColor clr; QColor clr;
@@ -59,16 +51,10 @@ void IntelliShapedImage::calculateVisiblity(){
imageData.setPixelColor(x,y,clr); imageData.setPixelColor(x,y,clr);
} }
} }
if(fastRenderer){
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData; QImage copy = imageData;
if(fastRenderer){
copy = copy.convertToFormat(QImage::Format_ARGB32);
}
for(int y = 0; y<copy.height(); y++) { for(int y = 0; y<copy.height(); y++) {
for(int x = 0; x<copy.width(); x++) { for(int x = 0; x<copy.width(); x++) {
QColor clr = copy.pixelColor(x,y); QColor clr = copy.pixelColor(x,y);
@@ -76,9 +62,6 @@ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
copy.setPixelColor(x,y, clr); copy.setPixelColor(x,y, clr);
} }
} }
if(fastRenderer){
copy = copy.convertToFormat(QImage::Format_Indexed8);
}
return copy.scaled(displaySize,Qt::IgnoreAspectRatio); return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
} }

View File

@@ -30,9 +30,8 @@ public:
* \brief The Construcor of the IntelliShapedImage. Given the Image dimensions. * \brief The Construcor of the IntelliShapedImage. Given the Image dimensions.
* \param width - The width of the Image. * \param width - The width of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
*/ */
IntelliShapedImage(int width, int height, bool fastRendererOn); IntelliShapedImage(int width, int height);
/*! /*!
* \brief An Destructor. * \brief An Destructor.

View File

@@ -21,7 +21,6 @@ SOURCES += \
Image/IntelliRasterImage.cpp \ Image/IntelliRasterImage.cpp \
Image/IntelliShapedImage.cpp \ Image/IntelliShapedImage.cpp \
IntelliHelper/IntelliColorPicker.cpp \ IntelliHelper/IntelliColorPicker.cpp \
IntelliHelper/IntelliRenderSettings.cpp \
IntelliHelper/IntelliToolsettings.cpp \ IntelliHelper/IntelliToolsettings.cpp \
IntelliHelper/IntelliTriangulation.cpp \ IntelliHelper/IntelliTriangulation.cpp \
Layer/PaintingArea.cpp \ Layer/PaintingArea.cpp \
@@ -41,7 +40,6 @@ HEADERS += \
Image/IntelliRasterImage.h \ Image/IntelliRasterImage.h \
Image/IntelliShapedImage.h \ Image/IntelliShapedImage.h \
IntelliHelper/IntelliColorPicker.h \ IntelliHelper/IntelliColorPicker.h \
IntelliHelper/IntelliRenderSettings.h \
IntelliHelper/IntelliToolsettings.h \ IntelliHelper/IntelliToolsettings.h \
IntelliHelper/IntelliTriangulation.h \ IntelliHelper/IntelliTriangulation.h \
Layer/PaintingArea.h \ Layer/PaintingArea.h \

View File

@@ -21,7 +21,6 @@
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
: QWidget(parent){ : QWidget(parent){
this->Tool = nullptr; this->Tool = nullptr;
this->renderSettings = IntelliRenderSettings();
this->setLayerDimensions(maxWidth, maxHeight); this->setLayerDimensions(maxWidth, maxHeight);
this->addLayer(200,200,0,0,IntelliImage::ImageType::Shaped_Image); this->addLayer(200,200,0,0,IntelliImage::ImageType::Shaped_Image);
layerBundle[0].image->drawPlain(QColor(0,0,255,255)); layerBundle[0].image->drawPlain(QColor(0,0,255,255));
@@ -37,7 +36,6 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
layerBundle[1].alpha=200; layerBundle[1].alpha=200;
activeLayer=0; activeLayer=0;
} }
PaintingArea::~PaintingArea(){ PaintingArea::~PaintingArea(){
@@ -48,8 +46,7 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
//set standart parameter //set standart parameter
this->maxWidth = maxWidth; this->maxWidth = maxWidth;
this->maxHeight = maxHeight; this->maxHeight = maxHeight;
if(renderSettings.getFastRenderer()) Canvas = new QImage(maxWidth,maxHeight, QImage::Format_Indexed8); Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
else Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
// Roots the widget to the top left even if resized // Roots the widget to the top left even if resized
setAttribute(Qt::WA_StaticContents); setAttribute(Qt::WA_StaticContents);
@@ -63,14 +60,11 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
newLayer.widthOffset = widthOffset; newLayer.widthOffset = widthOffset;
newLayer.heightOffset = heightOffset; newLayer.heightOffset = heightOffset;
if(type==IntelliImage::ImageType::Raster_Image) { if(type==IntelliImage::ImageType::Raster_Image) {
newLayer.image = new IntelliRasterImage(width,height,renderSettings.getFastRenderer()); newLayer.image = new IntelliRasterImage(width,height);
}else if(type==IntelliImage::ImageType::Shaped_Image) { }else if(type==IntelliImage::ImageType::Shaped_Image) {
newLayer.image = new IntelliShapedImage(width, height, renderSettings.getFastRenderer()); newLayer.image = new IntelliShapedImage(width, height);
} }
newLayer.alpha = 255;
newLayer.alpha = 255;
this->layerBundle.push_back(newLayer); this->layerBundle.push_back(newLayer);
return static_cast<int>(layerBundle.size())-1; return static_cast<int>(layerBundle.size())-1;
} }
@@ -124,7 +118,7 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
this->drawLayers(true); this->drawLayers(true);
if(!strcmp(fileFormat,"PNG")) { if(!strcmp(fileFormat,"PNG")) {
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8); QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
fileFormat = "png"; fileFormat = "png";
if (visibleImage.save(filePath, fileFormat)) { if (visibleImage.save(filePath, fileFormat)) {
return true; return true;
@@ -151,25 +145,21 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
} }
void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::movePositionActive(int x, int y){
if(Tool!=nullptr){ if(Tool->getIsDrawing()){
if(Tool->getIsDrawing()){ IntelliTool* temp = copyActiveTool();
IntelliTool* temp = copyActiveTool(); delete this->Tool;
delete this->Tool; this->Tool = temp;
this->Tool = temp;
}
} }
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x; layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y; layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
} }
void PaintingArea::moveActiveLayer(int idx){ void PaintingArea::moveActiveLayer(int idx){
if(Tool!=nullptr){ if(Tool->getIsDrawing()){
if(Tool->getIsDrawing()){ IntelliTool* temp = copyActiveTool();
IntelliTool* temp = copyActiveTool(); delete this->Tool;
delete this->Tool; this->Tool = temp;
this->Tool = temp; }
}
}
if(idx==1) { if(idx==1) {
this->selectLayerUp(); this->selectLayerUp();
}else if(idx==-1) { }else if(idx==-1) {
@@ -178,13 +168,11 @@ void PaintingArea::moveActiveLayer(int idx){
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
if(Tool!=nullptr){
if(Tool->getIsDrawing()){ if(Tool->getIsDrawing()){
IntelliTool* temp = copyActiveTool(); IntelliTool* temp = copyActiveTool();
delete this->Tool; delete this->Tool;
this->Tool = temp; this->Tool = temp;
} }
}
if(a>=0 && a < static_cast<int>(layerBundle.size())) { if(a>=0 && a < static_cast<int>(layerBundle.size())) {
this->setLayerActive(a); this->setLayerActive(a);
} }
@@ -314,7 +302,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
QPainter painter(this); QPainter painter(this);
QRect dirtyRec = event->rect(); QRect dirtyRec = event->rect();
painter.drawImage(dirtyRec, *Canvas, dirtyRec); painter.drawImage(dirtyRec, *Canvas, dirtyRec);
update(); update();
} }
@@ -345,17 +333,13 @@ void PaintingArea::selectLayerDown(){
void PaintingArea::drawLayers(bool forSaving){ void PaintingArea::drawLayers(bool forSaving){
if(forSaving) { if(forSaving) {
Canvas->fill(Qt::GlobalColor::transparent); Canvas->fill(Qt::GlobalColor::transparent);
}else{ }else{
Canvas->fill(Qt::GlobalColor::black); Canvas->fill(Qt::GlobalColor::black);
} }
for(size_t i=0; i<layerBundle.size(); i++) { for(size_t i=0; i<layerBundle.size(); i++) {
LayerObject layer = layerBundle[i]; LayerObject layer = layerBundle[i];
QImage cpy = layer.image->getDisplayable(layer.alpha); QImage cpy = layer.image->getDisplayable(layer.alpha);
if(renderSettings.getFastRenderer()){
cpy = cpy.convertToFormat(QImage::Format_ARGB32);
*Canvas = Canvas->convertToFormat(QImage::Format_ARGB32);
}
QColor clr_0; QColor clr_0;
QColor clr_1; QColor clr_1;
for(int y=0; y<layer.height; y++) { for(int y=0; y<layer.height; y++) {
@@ -364,7 +348,7 @@ void PaintingArea::drawLayers(bool forSaving){
for(int x=0; x<layer.width; x++) { for(int x=0; x<layer.width; x++) {
if(layer.widthOffset+x<0) continue; if(layer.widthOffset+x<0) continue;
if(layer.widthOffset+x>=maxWidth) break; if(layer.widthOffset+x>=maxWidth) break;
clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y); clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y);
clr_1=cpy.pixelColor(x,y); clr_1=cpy.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f; float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f); int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
@@ -380,9 +364,6 @@ void PaintingArea::drawLayers(bool forSaving){
} }
} }
} }
if(renderSettings.getFastRenderer()){
*Canvas = Canvas->convertToFormat(QImage::Format_Indexed8);
}
} }
void PaintingArea::createTempTopLayer(int idx){ void PaintingArea::createTempTopLayer(int idx){
@@ -410,3 +391,7 @@ IntelliTool* PaintingArea::copyActiveTool(){
default: return nullptr; default: return nullptr;
} }
} }
int PaintingArea::getNumberOfActiveLayer(){
return activeLayer;
}

View File

@@ -12,7 +12,6 @@
#include "Image/IntelliShapedImage.h" #include "Image/IntelliShapedImage.h"
#include "Tool/IntelliTool.h" #include "Tool/IntelliTool.h"
#include "IntelliHelper/IntelliColorPicker.h" #include "IntelliHelper/IntelliColorPicker.h"
#include "IntelliHelper/IntelliRenderSettings.h"
/*! /*!
* \brief The LayerObject struct holds all the information needed to construct a layer * \brief The LayerObject struct holds all the information needed to construct a layer
@@ -166,6 +165,8 @@ public:
std::vector<QPoint> getPolygonDataOfRealLayer(); std::vector<QPoint> getPolygonDataOfRealLayer();
int getNumberOfActiveLayer();
IntelliToolsettings Toolsettings; IntelliToolsettings Toolsettings;
IntelliColorPicker colorPicker; IntelliColorPicker colorPicker;
@@ -204,7 +205,6 @@ private:
int maxWidth; int maxWidth;
int maxHeight; int maxHeight;
IntelliRenderSettings renderSettings;
IntelliTool* Tool; IntelliTool* Tool;
std::vector<LayerObject> layerBundle; std::vector<LayerObject> layerBundle;

View File

@@ -57,9 +57,6 @@ void IntelliTool::createToolLayer(){
void IntelliTool::mergeToolLayer(){ void IntelliTool::mergeToolLayer(){
QColor clr_0; QColor clr_0;
QColor clr_1; QColor clr_1;
if(Area->renderSettings.getFastRenderer()){
activeLayer->image->imageData = activeLayer->image->imageData.convertToFormat(QImage::Format_ARGB32);
}
for(int y=0; y<activeLayer->height; y++) { for(int y=0; y<activeLayer->height; y++) {
for(int x=0; x<activeLayer->width; x++) { for(int x=0; x<activeLayer->width; x++) {
clr_0=activeLayer->image->imageData.pixelColor(x,y); clr_0=activeLayer->image->imageData.pixelColor(x,y);
@@ -77,9 +74,6 @@ void IntelliTool::mergeToolLayer(){
activeLayer->image->imageData.setPixelColor(x, y, clr_0); activeLayer->image->imageData.setPixelColor(x, y, clr_0);
} }
} }
if(Area->renderSettings.getFastRenderer()){
activeLayer->image->imageData = activeLayer->image->imageData.convertToFormat(QImage::Format_Indexed8);
}
} }
void IntelliTool::deleteToolLayer(){ void IntelliTool::deleteToolLayer(){

BIN
src/icons/Wechselpfeile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -16,36 +16,7 @@
<property name="animated"> <property name="animated">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget"/>
<widget class="QGraphicsView" name="graphicsView">
<property name="geometry">
<rect>
<x>120</x>
<y>100</y>
<width>256</width>
<height>192</height>
</rect>
</property>
<property name="backgroundBrush">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
<property name="foregroundBrush">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
</widget>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>