Matched HSVRGB to video

This commit is contained in:
Dawid Pietrykowski 2023-04-16 19:58:22 +02:00
parent 642b873704
commit 8fd16f569c

View File

@ -44,6 +44,8 @@ MyWindow::MyWindow(QWidget *parent) :
// i wysokosci. Ustawiamy format bitmapy na 32 bitowe RGB // i wysokosci. Ustawiamy format bitmapy na 32 bitowe RGB
// (0xffRRGGBB). // (0xffRRGGBB).
img = new QImage(szer,wys,QImage::Format_RGB32); img = new QImage(szer,wys,QImage::Format_RGB32);
DrawG(0);
} }
// Definicja destruktora // Definicja destruktora
@ -151,8 +153,8 @@ void MyWindow::DrawR(int r){
unsigned char* ptr = img->bits(); unsigned char* ptr = img->bits();
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
int b = ((float) i / img->width()) * 255.0f; int b = (((float) i / img->width())) * 255.0f;
int g = ((float) j / img->height()) * 255.0f; int g = (1.0f - ((float) j / img->height())) * 255.0f;
DrawPixel(img, i, j, QColor(r, g, b)); DrawPixel(img, i, j, QColor(r, g, b));
} }
} }
@ -163,8 +165,8 @@ void MyWindow::DrawG(int g){
unsigned char* ptr = img->bits(); unsigned char* ptr = img->bits();
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
int b = ((float) i / img->width()) * 255.0f; int r = ((float) i / img->width()) * 255.0f;
int r = ((float) j / img->height()) * 255.0f; int b = (1.0f - ((float) j / img->height())) * 255.0f;
DrawPixel(img, i, j, QColor(r, g, b)); DrawPixel(img, i, j, QColor(r, g, b));
} }
} }
@ -176,7 +178,7 @@ void MyWindow::DrawB(int b){
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
int g = ((float) i / img->width()) * 255.0f; int g = ((float) i / img->width()) * 255.0f;
int r = ((float) j / img->height()) * 255.0f; int r = (1.0f - ((float) j / img->height())) * 255.0f;
DrawPixel(img, i, j, QColor(r, g, b)); DrawPixel(img, i, j, QColor(r, g, b));
} }
} }
@ -188,8 +190,8 @@ void MyWindow::DrawH(float h){
unsigned char* ptr = img->bits(); unsigned char* ptr = img->bits();
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
float s = ((float) i / img->width()); float v = ((float) i / img->width());
float v = ((float) j / img->height()); float s = (1.0f - ((float) j / img->height()));
DrawPixel(img, i, j, HSVtoRGB(h, s, v)); DrawPixel(img, i, j, HSVtoRGB(h, s, v));
} }
} }
@ -201,7 +203,7 @@ void MyWindow::DrawS(float s){
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
float h = ((float) i / img->width()); float h = ((float) i / img->width());
float v = ((float) j / img->height()); float v = (1.0f - ((float) j / img->height()));
DrawPixel(img, i, j, HSVtoRGB(h, s, v)); DrawPixel(img, i, j, HSVtoRGB(h, s, v));
} }
} }
@ -213,7 +215,7 @@ void MyWindow::DrawV(float v){
for(int i = 0; i < img->width(); i++){ for(int i = 0; i < img->width(); i++){
for(int j = 0; j < img->height(); j++){ for(int j = 0; j < img->height(); j++){
float h = ((float) i / img->width()); float h = ((float) i / img->width());
float s = ((float) j / img->height()); float s = (1.0f - ((float) j / img->height()));
DrawPixel(img, i, j, HSVtoRGB(h, s, v)); DrawPixel(img, i, j, HSVtoRGB(h, s, v));
} }
} }