mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-18 06:10:29 +02:00
Halbfertig
weil Mucke es so wollte, keiner weiß warum
This commit is contained in:
@@ -77,3 +77,7 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
|
|||||||
void IntelliImage::drawPlain(const QColor& color){
|
void IntelliImage::drawPlain(const QColor& color){
|
||||||
imageData.fill(color);
|
imageData.fill(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor IntelliImage::getPixelColor(int x, int y){
|
||||||
|
return imageData.pixelColor(x,y);
|
||||||
|
}
|
||||||
|
|||||||
57
src/Image/IntelliImage.h.autosave
Normal file
57
src/Image/IntelliImage.h.autosave
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#ifndef INTELLIIMAGE_H
|
||||||
|
#define INTELLIIMAGE_H
|
||||||
|
|
||||||
|
#include<QImage>
|
||||||
|
#include<QPoint>
|
||||||
|
#include<QColor>
|
||||||
|
#include<QSize>
|
||||||
|
#include<QWidget>
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
|
enum class ImageType{
|
||||||
|
Raster_Image,
|
||||||
|
Shaped_Image
|
||||||
|
};
|
||||||
|
|
||||||
|
class IntelliTool;
|
||||||
|
|
||||||
|
class IntelliImage{
|
||||||
|
friend IntelliTool;
|
||||||
|
protected:
|
||||||
|
void resizeImage(QImage *image, const QSize &newSize);
|
||||||
|
|
||||||
|
QImage imageData;
|
||||||
|
|
||||||
|
//calculate with polygon
|
||||||
|
public:
|
||||||
|
IntelliImage(int weight, int height);
|
||||||
|
virtual ~IntelliImage() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
//start on top left
|
||||||
|
virtual void drawPixel(const QPoint &p1, const QColor& color);
|
||||||
|
virtual void drawPoint(const QPoint &p1, const QColor& color, const int& penWidth);
|
||||||
|
virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth);
|
||||||
|
virtual void drawPlain(const QColor& color);
|
||||||
|
|
||||||
|
//returns the filtered output
|
||||||
|
virtual QImage getDisplayable(const QSize& displaySize, int alpha)=0;
|
||||||
|
virtual QImage getDisplayable(int alpha=255)=0;
|
||||||
|
|
||||||
|
//gets a copy of the image !allocated
|
||||||
|
virtual IntelliImage* getDeepCopy()=0;
|
||||||
|
virtual void calculateVisiblity()=0;
|
||||||
|
|
||||||
|
//returns the filtered output
|
||||||
|
|
||||||
|
//sets the data for the visible image
|
||||||
|
virtual void setPolygon(const std::vector<QPoint>& polygonData)=0;
|
||||||
|
virtual std::vector<QPoint> getPolygonData(){ return std::vector<QPoint>();}
|
||||||
|
|
||||||
|
//loads an image to the ColorBuffer
|
||||||
|
virtual bool loadImage(const QString &fileName);
|
||||||
|
|
||||||
|
virtual QColor getPixelColor(int x, int y);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -25,6 +25,7 @@ SOURCES += \
|
|||||||
Layer/PaintingArea.cpp \
|
Layer/PaintingArea.cpp \
|
||||||
Tool/IntelliTool.cpp \
|
Tool/IntelliTool.cpp \
|
||||||
Tool/IntelliToolCircle.cpp \
|
Tool/IntelliToolCircle.cpp \
|
||||||
|
Tool/IntelliToolFloodFill.cpp \
|
||||||
Tool/IntelliToolLine.cpp \
|
Tool/IntelliToolLine.cpp \
|
||||||
Tool/IntelliToolPen.cpp \
|
Tool/IntelliToolPen.cpp \
|
||||||
Tool/IntelliToolPlain.cpp \
|
Tool/IntelliToolPlain.cpp \
|
||||||
@@ -41,6 +42,7 @@ HEADERS += \
|
|||||||
Layer/PaintingArea.h \
|
Layer/PaintingArea.h \
|
||||||
Tool/IntelliTool.h \
|
Tool/IntelliTool.h \
|
||||||
Tool/IntelliToolCircle.h \
|
Tool/IntelliToolCircle.h \
|
||||||
|
Tool/IntelliToolFloodFill.h \
|
||||||
Tool/IntelliToolLine.h \
|
Tool/IntelliToolLine.h \
|
||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h \
|
||||||
Tool/IntelliToolPlain.h \
|
Tool/IntelliToolPlain.h \
|
||||||
|
|||||||
82
src/Tool/IntelliTool.cpp.autosave
Normal file
82
src/Tool/IntelliTool.cpp.autosave
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#include"IntelliTool.h"
|
||||||
|
#include"Layer/PaintingArea.h"
|
||||||
|
|
||||||
|
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){
|
||||||
|
this->Area=Area;
|
||||||
|
this->colorPicker=colorPicker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IntelliTool::~IntelliTool(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onMouseRightPressed(int x, int y){
|
||||||
|
if(drawing){
|
||||||
|
drawing=false;
|
||||||
|
this->deleteToolLayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onMouseRightReleased(int x, int y){
|
||||||
|
//optional for tool
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onMouseLeftPressed(int x, int y){
|
||||||
|
this->drawing=true;
|
||||||
|
//create drawing layer
|
||||||
|
this->createToolLayer();
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||||
|
if(drawing){
|
||||||
|
drawing=false;
|
||||||
|
this->mergeToolLayer();
|
||||||
|
this->deleteToolLayer();
|
||||||
|
Active->image->calculateVisiblity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onMouseMoved(int x, int y){
|
||||||
|
if(drawing)
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::onWheelScrolled(int value){
|
||||||
|
//if needed for future general tasks implement in here
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::createToolLayer(){
|
||||||
|
Area->createTempLayerAfter(Area->activeLayer);
|
||||||
|
this->Active=&Area->layerBundle[Area->activeLayer];
|
||||||
|
this->Canvas=&Area->layerBundle[Area->activeLayer+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::mergeToolLayer(){
|
||||||
|
QColor clr_0;
|
||||||
|
QColor clr_1;
|
||||||
|
for(int y=0; y<Active->hight; y++){
|
||||||
|
for(int x=0; x<Active->width; x++){
|
||||||
|
clr_0=Active->image->imageData.pixelColor(x,y);
|
||||||
|
clr_1=Canvas->image->imageData.pixelColor(x,y);
|
||||||
|
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 g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f);
|
||||||
|
int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f);
|
||||||
|
int a =std::min(clr_0.alpha()+clr_1.alpha(), 255);
|
||||||
|
clr_0.setRed(r);
|
||||||
|
clr_0.setGreen(g);
|
||||||
|
clr_0.setBlue(b);
|
||||||
|
clr_0.setAlpha(a);
|
||||||
|
|
||||||
|
Active->image->imageData.setPixelColor(x, y, clr_0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliTool::deleteToolLayer(){
|
||||||
|
Area->deleteLayer(Area->activeLayer+1);
|
||||||
|
this->Canvas=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
38
src/Tool/IntelliTool.h.autosave
Normal file
38
src/Tool/IntelliTool.h.autosave
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef Intelli_Tool_H
|
||||||
|
#define Intelli_Tool_H
|
||||||
|
|
||||||
|
#include "IntelliHelper/IntelliColorPicker.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class LayerObject;
|
||||||
|
class PaintingArea;
|
||||||
|
|
||||||
|
class IntelliTool{
|
||||||
|
private:
|
||||||
|
void createToolLayer();
|
||||||
|
void mergeToolLayer();
|
||||||
|
void deleteToolLayer();
|
||||||
|
protected:
|
||||||
|
PaintingArea* Area;
|
||||||
|
IntelliColorPicker* colorPicker;
|
||||||
|
|
||||||
|
LayerObject* Active;
|
||||||
|
LayerObject* Canvas;
|
||||||
|
bool drawing = false;
|
||||||
|
|
||||||
|
public:
|
||||||
|
IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
|
virtual ~IntelliTool() = 0;
|
||||||
|
|
||||||
|
virtual void onMouseRightPressed(int x, int y);
|
||||||
|
virtual void onMouseRightReleased(int x, int y);
|
||||||
|
virtual void onMouseLeftPressed(int x, int y);
|
||||||
|
virtual void onMouseLeftReleased(int x, int y);
|
||||||
|
|
||||||
|
virtual void onWheelScrolled(int value);
|
||||||
|
|
||||||
|
virtual void onMouseMoved(int x, int y);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
64
src/Tool/IntelliToolFloodFill.cpp
Normal file
64
src/Tool/IntelliToolFloodFill.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#include "IntelliToolFloodFill.h"
|
||||||
|
#include "Layer/PaintingArea.h"
|
||||||
|
#include "QColorDialog"
|
||||||
|
#include "QInputDialog"
|
||||||
|
|
||||||
|
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
|
:IntelliTool(Area, colorPicker){
|
||||||
|
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
|
||||||
|
//create checkbox or scroll dialog to get line style
|
||||||
|
this->lineStyle = LineStyle::SOLID_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntelliToolLine::~IntelliToolLine(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IntelliToolLine::onMouseRightPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolLine::onMouseRightReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseRightReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
|
this->start=QPoint(x,y);
|
||||||
|
this->Canvas->image->drawLine(start, start, colorPicker->getFirstColor(),lineWidth);
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolLine::onMouseLeftReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolLine::onWheelScrolled(int value){
|
||||||
|
IntelliTool::onWheelScrolled(value);
|
||||||
|
this->lineWidth+=value;
|
||||||
|
if(this->lineWidth<=0){
|
||||||
|
this->lineWidth=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolLine::onMouseMoved(int x, int y){
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
if(this->drawing){
|
||||||
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
|
QPoint next(x,y);
|
||||||
|
switch(lineStyle){
|
||||||
|
case LineStyle::SOLID_LINE:
|
||||||
|
this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
|
||||||
|
break;
|
||||||
|
case LineStyle::DOTTED_LINE:
|
||||||
|
QPoint p1 =start.x() <= next.x() ? start : next;
|
||||||
|
QPoint p2 =start.x() < next.x() ? next : start;
|
||||||
|
int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f;
|
||||||
|
int c = start.y()-start.x()*m;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
}
|
||||||
66
src/Tool/IntelliToolFloodFill.cpp.autosave
Normal file
66
src/Tool/IntelliToolFloodFill.cpp.autosave
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#include "IntelliToolFloodFill.h"
|
||||||
|
#include "Layer/PaintingArea.h"
|
||||||
|
#include "QColorDialog"
|
||||||
|
#include "QInputDialog"
|
||||||
|
|
||||||
|
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
|
:IntelliTool(Area, colorPicker){
|
||||||
|
}
|
||||||
|
|
||||||
|
IntelliToolFloodFill::~IntelliToolFloodFill(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onMouseRightPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onMouseRightReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseRightReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
|
this->Canvas->image->get
|
||||||
|
auto depthsearch = [](int x, int y, LayerObject* Canvas){
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onMouseLeftReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onWheelScrolled(int value){
|
||||||
|
IntelliTool::onWheelScrolled(value);
|
||||||
|
this->lineWidth+=value;
|
||||||
|
if(this->lineWidth<=0){
|
||||||
|
this->lineWidth=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolFloodFill::onMouseMoved(int x, int y){
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
if(this->drawing){
|
||||||
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
|
QPoint next(x,y);
|
||||||
|
switch(lineStyle){
|
||||||
|
case LineStyle::SOLID_LINE:
|
||||||
|
this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
|
||||||
|
break;
|
||||||
|
case LineStyle::DOTTED_LINE:
|
||||||
|
QPoint p1 =start.x() <= next.x() ? start : next;
|
||||||
|
QPoint p2 =start.x() < next.x() ? next : start;
|
||||||
|
int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f;
|
||||||
|
int c = start.y()-start.x()*m;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
}
|
||||||
23
src/Tool/IntelliToolFloodFill.h
Normal file
23
src/Tool/IntelliToolFloodFill.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef INTELLITOOLFLOODFILL_H
|
||||||
|
#define INTELLITOOLFLOODFILL_H
|
||||||
|
#include "IntelliTool.h"
|
||||||
|
|
||||||
|
#include "QColor"
|
||||||
|
|
||||||
|
class IntelliToolFloodFill : public IntelliTool{
|
||||||
|
public:
|
||||||
|
IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
|
virtual ~IntelliToolFloodFill() override;
|
||||||
|
|
||||||
|
|
||||||
|
virtual void onMouseRightPressed(int x, int y) override;
|
||||||
|
virtual void onMouseRightReleased(int x, int y) override;
|
||||||
|
virtual void onMouseLeftPressed(int x, int y) override;
|
||||||
|
virtual void onMouseLeftReleased(int x, int y) override;
|
||||||
|
|
||||||
|
virtual void onWheelScrolled(int value) override;
|
||||||
|
|
||||||
|
virtual void onMouseMoved(int x, int y) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INTELLITOOLFLOODFILL_H
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
#define INTELLITOOLLINE_H
|
#define INTELLITOOLLINE_H
|
||||||
#include "IntelliTool.h"
|
#include "IntelliTool.h"
|
||||||
|
|
||||||
#include "QColor"
|
|
||||||
#include "QPoint"
|
#include "QPoint"
|
||||||
|
|
||||||
enum class LineStyle{
|
enum class LineStyle{
|
||||||
|
|||||||
Reference in New Issue
Block a user