diff --git a/QT/triangle-textures/c.jpg b/QT/triangle-textures/c.jpg
new file mode 100644
index 0000000..8e62ee8
Binary files /dev/null and b/QT/triangle-textures/c.jpg differ
diff --git a/QT/triangle-textures/mywindow.cpp b/QT/triangle-textures/mywindow.cpp
index 0c18c69..416c498 100644
--- a/QT/triangle-textures/mywindow.cpp
+++ b/QT/triangle-textures/mywindow.cpp
@@ -98,7 +98,7 @@ MyWindow::MyWindow(QWidget *parent) :
f1_img = new QImage(szer,wys,QImage::Format_RGB32);
f2_img = new QImage(szer,wys,QImage::Format_RGB32);
- loaded_img1 = new QImage("/home/davp/umk/2022_2023/GK/QT/alpha-blending/f.png");
+ loaded_img1 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/triangle-textures/c.jpg");
// int width = loaded_img1->width();
// int height = loaded_img1->height();
@@ -139,26 +139,6 @@ void MyWindow::on_exitButton_clicked()
qApp->quit();
}
-void MyWindow::on_erosion_clicked(){
- Erosion(loaded_img1);
- UpdateImage();
-}
-
-void MyWindow::on_dilation_clicked(){
- Dilation(loaded_img1);
- UpdateImage();
-}
-
-void MyWindow::on_opening_clicked(){
- Open(loaded_img1);
- UpdateImage();
-}
-
-void MyWindow::on_closing_clicked(){
- Close(loaded_img1);
- UpdateImage();
-}
-
void MyWindow::UpdateImage(){
ClearImage(f1_img);
ClearImage(f2_img);
@@ -170,62 +150,6 @@ void MyWindow::UpdateImage(){
update();
}
-bool MyWindow::IsLit(QImage* im, int x, int y, int val){
- int width = im->width();
- int height = im->height();
- if(x < 0 || y < 0 || x >= width || y >= height)
- return false;
- QColor pix = GetPixel(im, x, y);
- return pix.red() == val && pix.green() == val && pix.blue() == val;
-}
-
-void MyWindow::Erosion(QImage* im){
- int width = im->width();
- int height = im->height();
-
- memcpy(loaded_img2->bits(), loaded_img1->bits(), width * height * 4);
-
- for(int x = 0; x < width; x++)
- for(int y = 0; y < height; y++){
- bool active = false;
- for (int x2 = x - 1; x2 <= x + 1; x2++)
- for (int y2 = y - 1; y2 <= y + 1; y2++)
- if(IsLit(loaded_img1, x2, y2, 0)){
- DrawPixel(loaded_img2, x, y, QColor(0, 0, 0));
- break;
- }
- }
- memcpy(loaded_img1->bits(), loaded_img2->bits(), width * height * 4);
-}
-
-void MyWindow::Dilation(QImage* im){
- int width = im->width();
- int height = im->height();
-
- memcpy(loaded_img2->bits(), loaded_img1->bits(), width * height * 4);
-
- for(int x = 0; x < width; x++)
- for(int y = 0; y < height; y++){
- bool active = false;
- for (int x2 = x - 1; x2 <= x + 1; x2++)
- for (int y2 = y - 1; y2 <= y + 1; y2++)
- if(IsLit(loaded_img1, x2, y2, 255)){
- DrawPixel(loaded_img2, x, y, QColor(255, 255, 255));
- break;
- }
- }
- memcpy(loaded_img1->bits(), loaded_img2->bits(), width * height * 4);
-}
-
-void MyWindow::Close(QImage* im){
- Dilation(im);
- Erosion(im);
-}
-
-void MyWindow::Open(QImage* im){
- Erosion(im);
- Dilation(im);
-}
QColor MyWindow::GetPixel(QImage* img, int x, int y){
QColor res;
diff --git a/QT/triangle-textures/mywindow.h b/QT/triangle-textures/mywindow.h
index fc1c4fa..9bb50b0 100644
--- a/QT/triangle-textures/mywindow.h
+++ b/QT/triangle-textures/mywindow.h
@@ -39,9 +39,9 @@ enum Mode {Add, Move, None};
struct Point{
- int x, y;
+ float x, y;
- Point(int x, int y){
+ Point(float x, float y){
this->x=x;
this->y=y;
}
@@ -53,10 +53,6 @@ struct Point{
Point operator-(const Point& other){
return Point(this->x - other.x, this->y - other.y);
- // float x = other.x - this->x;
- // float y = other.y - this->y;
- // float mag = std::sqrt(std::pow(x, 2) + std::pow(y, 2));
- // return mag;
}
Point operator*(const float mul){
@@ -154,25 +150,13 @@ private:
void UpdateImage();
- bool IsLit(QImage* im, int x, int y, int val);
- void Erosion(QImage* im);
- void Dilation(QImage* im);
- void Close(QImage* im);
- void Open(QImage* im);
int FindPoint(int x, int y, float radius, int frame);
void DrawTriangles();
void DrawSquare(QImage* im, int x, int y, int size, QColor color);
void DrawLine(QImage *im, int x1, int y1, int x2, int y2);
- // Deklaracje slotow, czyli funkcji wywolywanych
- // po wystapieniu zdarzen zwiazanych z GUI
- // np. klikniecie na przycisk, ruch myszka
private slots:
void on_exitButton_clicked();
void paintEvent(QPaintEvent*);
- void on_erosion_clicked();
- void on_dilation_clicked();
- void on_opening_clicked();
- void on_closing_clicked();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
diff --git a/QT/triangle-textures/mywindow.ui b/QT/triangle-textures/mywindow.ui
index a127b52..11c2e99 100644
--- a/QT/triangle-textures/mywindow.ui
+++ b/QT/triangle-textures/mywindow.ui
@@ -39,9 +39,9 @@
- 980
- 460
- 241
+ 10
+ 610
+ 200
201
@@ -61,58 +61,6 @@
Wyjście
-
-
-
- 30
- 80
- 80
- 25
-
-
-
- Erozja
-
-
-
-
-
- 30
- 140
- 80
- 25
-
-
-
- Otwarcie
-
-
-
-
-
- 140
- 80
- 80
- 25
-
-
-
- Dylacja
-
-
-
-
-
- 140
- 140
- 80
- 25
-
-
-
- Zamknięcie
-
-
@@ -140,7 +88,7 @@
0
0
1236
- 22
+ 24