Minor bugfixes, changed images for alpha-blending
This commit is contained in:
parent
902a512061
commit
2439cb0a07
BIN
QT/alpha-blending/l0.png
Normal file
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
BIN
QT/alpha-blending/l1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
@ -48,7 +48,6 @@ std::vector<float> matrixMul3x3(std::vector<float> m1, std::vector<float> m2)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QColor mul(float v, QColor c){
|
QColor mul(float v, QColor c){
|
||||||
int red = (int)(c.red() * v);
|
int red = (int)(c.red() * v);
|
||||||
if(red > 255) red = 255;
|
if(red > 255) red = 255;
|
||||||
@ -56,7 +55,9 @@ QColor mul(float v, QColor c){
|
|||||||
if(green > 255) green = 255;
|
if(green > 255) green = 255;
|
||||||
int blue = (int)(c.blue() * v);
|
int blue = (int)(c.blue() * v);
|
||||||
if(blue > 255) blue = 255;
|
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){
|
QColor add(QColor c1, QColor c2){
|
||||||
@ -66,7 +67,9 @@ QColor add(QColor c1, QColor c2){
|
|||||||
if(green > 255) green = 255;
|
if(green > 255) green = 255;
|
||||||
int blue = (int)(c1.blue() + c2.blue());
|
int blue = (int)(c1.blue() + c2.blue());
|
||||||
if(blue > 255) blue = 255;
|
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
|
// Definicja konstruktora, wywolujemy najpierw
|
||||||
// konstruktor klasy nadrzednej, nastepnie tworzymy
|
// konstruktor klasy nadrzednej, nastepnie tworzymy
|
||||||
@ -94,12 +97,16 @@ MyWindow::MyWindow(QWidget *parent) :
|
|||||||
// (0xffRRGGBB).
|
// (0xffRRGGBB).
|
||||||
img = new QImage(szer,wys,QImage::Format_RGB32);
|
img = new QImage(szer,wys,QImage::Format_RGB32);
|
||||||
|
|
||||||
loaded_img1 = new QImage("/home/davp/umk/2022_2023/GK/QT/alpha-blending/p.png");
|
// loaded_img1 = new QImage("/Users/dawidpietrykowski/Desktop/projects/umk/GK/QT/alpha-blending/p.png");
|
||||||
loaded_img2 = new QImage("/home/davp/umk/2022_2023/GK/QT/alpha-blending/f.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;
|
rotation_angle = 0;
|
||||||
|
|
||||||
|
|
||||||
|
alpha = 0;
|
||||||
|
|
||||||
UpdateImage();
|
UpdateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,9 @@ QColor mul(float v, QColor c){
|
|||||||
if(green > 255) green = 255;
|
if(green > 255) green = 255;
|
||||||
int blue = (int)(c.blue() * v);
|
int blue = (int)(c.blue() * v);
|
||||||
if(blue > 255) blue = 255;
|
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){
|
QColor add(QColor c1, QColor c2){
|
||||||
@ -66,7 +68,9 @@ QColor add(QColor c1, QColor c2){
|
|||||||
if(green > 255) green = 255;
|
if(green > 255) green = 255;
|
||||||
int blue = (int)(c1.blue() + c2.blue());
|
int blue = (int)(c1.blue() + c2.blue());
|
||||||
if(blue > 255) blue = 255;
|
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
|
// Definicja konstruktora, wywolujemy najpierw
|
||||||
// konstruktor klasy nadrzednej, nastepnie tworzymy
|
// konstruktor klasy nadrzednej, nastepnie tworzymy
|
||||||
@ -117,6 +121,8 @@ MyWindow::MyWindow(QWidget *parent) :
|
|||||||
DrawPixel(img, x, y, color);
|
DrawPixel(img, x, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateImage();
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user