Minor bugfixes, changed images for alpha-blending

This commit is contained in:
Dawid Pietrykowski 2023-05-14 10:14:50 +02:00
parent 902a512061
commit 2439cb0a07
4 changed files with 20 additions and 7 deletions

BIN
QT/alpha-blending/l0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

BIN
QT/alpha-blending/l1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -48,7 +48,6 @@ std::vector<float> matrixMul3x3(std::vector<float> m1, std::vector<float> m2)
return res;
}
QColor mul(float v, QColor c){
int red = (int)(c.red() * v);
if(red > 255) red = 255;
@ -56,7 +55,9 @@ QColor mul(float v, QColor c){
if(green > 255) green = 255;
int blue = (int)(c.blue() * v);
if(blue > 255) blue = 255;
return QColor(red, green, blue);
int alpha = (int)(c.alpha() * v);
if(alpha > 255) alpha = 255;
return QColor(red, green, blue, alpha);
}
QColor add(QColor c1, QColor c2){
@ -66,7 +67,9 @@ QColor add(QColor c1, QColor c2){
if(green > 255) green = 255;
int blue = (int)(c1.blue() + c2.blue());
if(blue > 255) blue = 255;
return QColor(red, green, blue);
int alpha = (int)(c1.alpha() + c2.alpha());
if(alpha > 255) alpha = 255;
return QColor(red, green, blue, alpha);
}
// Definicja konstruktora, wywolujemy najpierw
// konstruktor klasy nadrzednej, nastepnie tworzymy
@ -94,12 +97,16 @@ MyWindow::MyWindow(QWidget *parent) :
// (0xffRRGGBB).
img = new QImage(szer,wys,QImage::Format_RGB32);
loaded_img1 = new QImage("/home/davp/umk/2022_2023/GK/QT/alpha-blending/p.png");
loaded_img2 = new QImage("/home/davp/umk/2022_2023/GK/QT/alpha-blending/f.png");
// loaded_img1 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/alpha-blending/p.png");
// loaded_img2 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/alpha-blending/f.png");
loaded_img1 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/alpha-blending/l0.png");
loaded_img2 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/alpha-blending/l1.png");
rotation_angle = 0;
alpha = 0;
UpdateImage();
}

View File

@ -56,7 +56,9 @@ QColor mul(float v, QColor c){
if(green > 255) green = 255;
int blue = (int)(c.blue() * v);
if(blue > 255) blue = 255;
return QColor(red, green, blue);
int alpha = (int)(c.alpha() * v);
if(alpha > 255) alpha = 255;
return QColor(red, green, blue, alpha);
}
QColor add(QColor c1, QColor c2){
@ -66,7 +68,9 @@ QColor add(QColor c1, QColor c2){
if(green > 255) green = 255;
int blue = (int)(c1.blue() + c2.blue());
if(blue > 255) blue = 255;
return QColor(red, green, blue);
int alpha = (int)(c1.alpha() + c2.alpha());
if(alpha > 255) alpha = 255;
return QColor(red, green, blue, alpha);
}
// Definicja konstruktora, wywolujemy najpierw
// konstruktor klasy nadrzednej, nastepnie tworzymy
@ -117,6 +121,8 @@ MyWindow::MyWindow(QWidget *parent) :
DrawPixel(img, x, y, color);
}
UpdateImage();
update();
}