Go to the documentation of this file.
62 for(
auto& layer : layerBundle) {
63 layer.image->updateRendererSetting(isFastRenderingOn);
74 this->maxWidth = newMaxWidth;
75 this->maxHeight = newMaxHeight;
76 Canvas =
new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
78 this->offsetXDimension = maxWidth / 2;
79 this->offsetYDimension = maxHeight / 2;
82 setAttribute(Qt::WA_StaticContents);
87 layerBundle[
static_cast<size_t>(activeLayer)].image->drawPixel(point, color);
91 layerBundle[
static_cast<size_t>(activeLayer)].image->setPolygon(points);
97 newLayer.
width = width;
101 newLayer.
alpha = alpha;
107 this->layerBundle.push_back(newLayer);
108 activeLayer =
static_cast<int>(layerBundle.size()) - 1;
117 if(idx<
static_cast<int>(layerBundle.size())&&idx>=0) {
118 this->layerBundle.erase(layerBundle.begin() + idx);
119 if(activeLayer>=idx) {
122 if(activeLayer < 0 && layerBundle.size()) {
129 if(activeLayer>=0 && activeLayer <
static_cast<int>(layerBundle.size())) {
130 this->layerBundle.erase(layerBundle.begin() + activeLayer);
138 if(idx>=0&&idx<
static_cast<int>(layerBundle.size())) {
139 this->activeLayer = idx;
144 if(idx>=0&&idx<
static_cast<int>(layerBundle.size())) {
145 if(alpha>=0 && alpha<=255) {
146 layerBundle[
static_cast<size_t>(idx)].alpha = alpha;
151 if(idx>=0&&idx<
static_cast<int>(layerBundle.size())) {
155 isSettingPolygon =
true;
163 if(this->activeLayer==-1) {
166 IntelliImage* active = layerBundle[
static_cast<size_t>(activeLayer)].image;
174 for(
auto layer: layerBundle) {
182 if(layerBundle.size()==0) {
185 this->drawLayers(
true);
187 if(!strcmp(fileFormat,
"PNG")) {
188 QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
190 if (visibleImage.save(filePath, fileFormat)) {
197 if (Canvas->save(filePath, fileFormat)) {
206 layerBundle[
static_cast<size_t>(activeLayer)].widthOffset += x;
207 layerBundle[
static_cast<size_t>(activeLayer)].heightOffset += y;
214 this->selectLayerUp();
216 this->selectLayerDown();
224 if(a>=0 && a <
static_cast<int>(layerBundle.size())) {
230 QColor clr = QColorDialog::getColor(
colorPicker.
getFirstColor(),
nullptr,
"Main Color", QColorDialog::DontUseNativeDialog);
235 QColor clr = QColorDialog::getColor(
colorPicker.
getSecondColor(),
nullptr,
"Secondary Color", QColorDialog::DontUseNativeDialog);
283 return this->layerBundle[
static_cast<size_t>(activeLayer)].width;
287 return this->layerBundle[
static_cast<size_t>(activeLayer)].height;
291 return this->maxWidth;
295 return this->maxHeight;
299 return this->layerBundle[
static_cast<size_t>(activeLayer)].image->getTypeOfImage();
303 return this->layerBundle[
static_cast<size_t>(activeLayer)].image->getPolygonData();
310 if(this->activeLayer < 0) {
315 int x =
event->x() - layerBundle[
static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
316 int y =
event->y() - layerBundle[
static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
317 if(event->button() == Qt::LeftButton) {
319 }
else if(event->button() == Qt::RightButton) {
329 if(this->activeLayer < 0) {
334 int x =
event->x() - layerBundle[
static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
335 int y =
event->y() - layerBundle[
static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
342 if(this->activeLayer < 0)
346 int x =
event->x() - layerBundle[
static_cast<size_t>(activeLayer)].widthOffset - offsetXDimension;
347 int y =
event->y() - layerBundle[
static_cast<size_t>(activeLayer)].heightOffset - offsetYDimension;
348 if(event->button() == Qt::LeftButton) {
350 }
else if(event->button() == Qt::RightButton) {
357 if(this->activeLayer < 0)
359 if(this->Tool !=
nullptr) {
360 QPoint numDegrees =
event->angleDelta() / 8;
361 if(!numDegrees.isNull()) {
362 QPoint numSteps = numDegrees / 15;
372 this->setFixedSize(QSize(maxWidth * 2,maxHeight * 2));
375 QPainter painter(
this);
382 painter.drawImage(0, 0, *Canvas, -offsetXDimension, -offsetYDimension);
386 void PaintingArea::selectLayerUp(){
388 if(activeLayer != -1 &&
static_cast<size_t>(activeLayer)<layerBundle.size() - 1) {
389 std::swap(layerBundle[
static_cast<size_t>(activeLayer)], layerBundle[
static_cast<size_t>(activeLayer + 1)]);
394 void PaintingArea::selectLayerDown(){
397 std::swap(layerBundle[
static_cast<size_t>(activeLayer)], layerBundle[
static_cast<size_t>(activeLayer - 1)]);
402 void PaintingArea::drawLayers(
bool forSaving){
404 Canvas->fill(Qt::GlobalColor::transparent);
406 Canvas->fill(Qt::GlobalColor::black);
408 for(
size_t i = 0; i<layerBundle.size(); i++) {
413 for(
int y = 0; y<layer.
height; y++) {
416 for(
int x = 0; x<layer.
width; x++) {
420 clr_1 = cpy.pixelColor(x,y);
421 float t =
static_cast<float>(clr_1.alpha()) / 255.f;
422 int r =
static_cast<int>(
static_cast<float>(clr_1.red()) * (t) +
static_cast<float>(clr_0.red()) * (1.f - t) + 0.5f);
423 int g =
static_cast<int>(
static_cast<float>(clr_1.green()) * (t) +
static_cast<float>(clr_0.green()) * (1.f - t) + 0.5f);
424 int b =
static_cast<int>(
static_cast<float>(clr_1.blue()) * (t) +
static_cast<float>(clr_0.blue() * (1.f - t)) + 0.5f);
425 int a = std::min(clr_0.alpha() + clr_1.alpha(), 255);
437 bool PaintingArea::createTempTopLayer(
int idx){
440 newLayer.
alpha = 255;
441 newLayer.
height = layerBundle[
static_cast<size_t>(idx)].height;
442 newLayer.
width = layerBundle[
static_cast<size_t>(idx)].width;
443 newLayer.
heightOffset = layerBundle[
static_cast<size_t>(idx)].heightOffset;
444 newLayer.
widthOffset = layerBundle[
static_cast<size_t>(idx)].widthOffset;
445 newLayer.
image = layerBundle[
static_cast<size_t>(idx)].image->getDeepCopy();
446 layerBundle.insert(layerBundle.begin() + idx + 1,newLayer);
463 default:
return nullptr;
475 return layerBundle[
static_cast<size_t>(activeLayer)].image;
481 returnImage = QImage(QSize(10,10),QImage::Format_ARGB32);
482 returnImage.fill(QColor(255,255,255,255));
485 returnImage = layerBundle[
static_cast<size_t>(activeLayer)].image->getImageData();
487 returnImage = returnImage.convertToFormat(QImage::Format_ARGB32);
497 void PaintingArea::updateTools(){
504 if(isSettingPolygon) {
506 this->Tool =
nullptr;
507 isSettingPolygon =
false;
514 history.erase(history.begin() + historyPresent + 1,history.end());
516 history.push_back(layerBundle);
521 if( historyPresent<0) {
524 layerBundle = history[
static_cast<size_t>(historyPresent)];
530 if(historyPresent>=
static_cast<int>(history.size())) {
531 historyPresent =
static_cast<int>(history.size() - 1);
533 layerBundle = history[
static_cast<size_t>(historyPresent)];
int getWidthOfActive()
The getWidthOfActive gets the horizontal dimensions of the active layer.
void createCircleTool()
createCircleTool creates a Circle Tool.
QColor getFirstColor() const
A function to read the primary selected color.
ImageType
The Types, which an Image can be.
void setRenderSettings(bool isFastRenderingOn)
setRenderSettings updates all Images to the new Rendersetting.
IntelliImage * getImageOfActiveLayer()
getImageOfActiveLayer returns the image of the active Layer.
void mouseReleaseEvent(QMouseEvent *event) override
mouseReleaseEvent handles a mouse released event
void createRectangleTool()
createRectangleTool creates a Rectangle Tool.
int getMaxWidth()
getMaxWidth gets the max width of the Canvas.
PaintingArea(int newMaxWidth=600, int newMaxHeight=600, QWidget *parent=nullptr)
PaintingArea is the constructor of the PaintingArea class, which initiates the working environment.
bool isFastRenderering() const
The getfastRenderer gets the value of the flag for the fastRenderer setting.
bool save(const QString &filePath, const char *fileFormat)
The save method is used for exporting the current project as one picture.
void setLayerAlpha(int idx, int alpha)
The setAlphaOfLayer method sets the alpha value of a specific layer.
std::vector< QPoint > getPolygonDataOfActiveLayer()
getPolygonDataOfActiveLayer get the polygon data of the active Layer.
void setLayerActive(int idx)
The setLayerToActive method marks a specific layer as active.
int widthOffset
widthOffset - Stores the number of pixles from the left side of the painting area.
int getMaxHeight()
getMaxHeight gets the max height of the Canvas.
void deleteLayer(int idx, bool isTool=false)
The deleteLayer method removes a layer at a given idx.
void setSecondColor(QColor Color)
A function to set the secondary color.
The IntelliShapedImage manages a Shapedimage.
int heightOffset
heightOffset - Stores the number of pixles from the top of the painting area.
int getHeightOfActive()
The getHeightOfActive gets the vertical dimensions of the active layer.
virtual QImage getDisplayable(const QSize &displaySize, int alpha)=0
A function returning the displayable ImageData in a requested transparence and size.
void createPlainTool()
createPlainTool creates a Plain Tool.
void wheelEvent(QWheelEvent *event) override
wheelEvent handles a mouse wheel event
virtual ImageType getTypeOfImage()
The LayerObject struct holds all the information needed to construct a layer.
void createPenTool()
createPenTool creates a Pen Tool.
void mousePressEvent(QMouseEvent *event) override
mousePressEvent handles a mouse pressed event.
int alpha
alpha - Stores the alpha value of the layer (default=255).
QColor getSecondColor() const
A function to read the secondary selected color.
int getIndexOfActiveLayer()
getIndexOfActiveLayer returns the index of athe active Layer.
void drawPixelOntoActive(QColor color, QPoint point)
drawPixelOntoActive draws a pixel onto the image data of the active Layer.
void historyGoBack()
historyGoBack go back in hisotry
void createLineTool()
createLineTool creates a Line Tool.
void colorPickerSetSecondColor()
The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color.
void colorPickerSetFirstColor()
The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color.
std::vector< LayerObject > * getLayerBundle()
getLayerBundle returns the real active layerbundle (care!)
int width
width - Stores the width of a layer in pixels.
~PaintingArea() override
This deconstructor is used to clear up the memory and remove the currently active window.
void mouseMoveEvent(QMouseEvent *event) override
mouseMoveEvent handles a mouse moved event
void setFirstColor(QColor Color)
A function to set the primary color.
void slotDeleteActiveLayer()
The slotDeleteActiveLayer method handles the deletion of the active layer.
ImageType getTypeOfImageActiveLayer()
getTypeOfImageActiveLayer get the type of the active Layer.
void setToolWidth(int value)
setToolWidth stes a width to the tool
bool open(const QString &filePath)
The open method is used for loading a picture into the current layer.
void createPolygonTool()
createPolygonTool creates a Polygon Tool.
void moveActiveLayer(int idx)
The moveActiveLayer moves the active layer to a specific position in the layer stack.
IntelliColorPicker colorPicker
colorPicker a class to manage Tool color.
int height
height - Stores the height of a layer in pixels.
void deleteAllLayers()
deleteAllLayers deletes all layers
QImage getImageDataOfActiveLayer()
getImageDataOfActiveLayer used to get the currents active imageData (if there isn't any active layer ...
void createFloodFillTool()
createFloodFillTool creates a Floodfill Tool.
void slotActivateLayer(int a)
The slotActivateLayer method handles the event of selecting one layer as active.
void setCanvasDimensions(int newMaxWidth, int newMaxHeight)
setCanvasDimensions sets the dimension of the Canvas
void paintEvent(QPaintEvent *event) override
paintEvent handles a painting event
void setFastRendering(bool Updatedsetting)
setFastRendering sets fastRendering to Updatedsetting.
void UpdateGui()
UpdateGui a function to update all gui elements.
bool getRenderSettings()
getRenderSettings updates all Images to the new Rendersetting.
IntelliImage * image
image - Stores the imageData of the current LayerObject.
virtual bool loadImage(const QString &filePath)
A function that loads and sclaes an image to the fitting dimensions.
IntelliToolsettings Toolsettings
Toolsettings - a class to manage Tool settings.
void setPolygon(int idx)
setPolygon is used for setting polygondata, it only works on RASTER images
void swapColors()
A function switching primary and secondary color.
void colorPickerSwapColors()
The colorPickerSwitchColor swaps the primary color with the secondary drawing color.
void movePositionActive(int x, int y)
The movePositionActive method moves the active layer to certain position.
An abstract class which manages the basic IntelliImage operations.
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, int alpha=255, ImageType type=ImageType::RASTERIMAGE)
The addLayer adds a layer to the current project/ painting area.
void historyGoForward()
historyGoForward a function to undo the return of the previous state of the project.
virtual void calculateVisiblity()=0
An abstract function that calculates the visiblity of the Image data if needed.
void historyadd()
historyadd adds an hisotry step
The IntelliRasterImage manages a RASTERIMAGE.
void setPolygonDataToActive(std::vector< QPoint > points)
setPolygonDataToActive sets polygondata to the active Layer.
void createGradientTool()
createGradientTool creates a Gradient Tool.