Hi
i have to convert immagine jpg into Rgb and convert in grey.
Can you suggest?
Hi
i have to convert immagine jpg into Rgb and convert in grey.
Can you suggest?
i can try with for but i dont understand the functions to use.
for example:
QPixmap pix(":/pathFile/NameFile.jpg"); //
//
for (int ii = 0; ii < pix.height(); ii++) {
for (int jj = 0; jj < pix.width(); jj++) {
// qGray(1,1,1);
}
}
Added after 1 41 minutes:
QImage immagine(":/PATH/IMMAGINE.jpg");
QRgb color;
for (int ii = 0; ii < immagine.height(); ii++) {
for (int jj = 0; jj < immagine.width(); jj++) {
color = immagine.pixel(ii,jj);
immagine.setPixel(ii,jj,QColor((qRed(color)*0.3) + qGreen(color)*0.59 + qBlue(color)*0.11).rgb());
}
Last edited by montanaro; 19th July 2018 at 10:10.
It returned:
QImage:ixel: coordinate (199,822) out of range
i solvede into Windows:
"
QSize sizeImage = immagine.size();
int width = sizeImage.width(), height = sizeImage.height();
QRgb color;
for (int f1=0; f1<width; f1++) {
for (int f2=0; f2<height; f2++) {
color = immagine.pixel(f1, f2);
// color= immagine.pixel(j,i);
// image.setPixel(f1, f2, QColor((qRed(color) + qGreen(color) + qBlue(color))/3).rgb());
int grigio= qGray(color);
immagine.setPixel(f1,f2, qRgb(grigio, grigio, grigio));
}
}"
but when i use qt on linux virtual machine, it dont run
virtual machine says: " conncection refused"
you can suggest ?
i changed ip in qt option and now it runs
but now my duty is porting in QML
how i can? :O
Bookmarks