title: Image converter in Qt, colored image to black-white
body: <p>I am trying to make a simple program that converts colored images to black-white images.</p>
  
  <p>So far I have made this.</p>
  
  <pre><code>void ObradaSlike::convert_picture_to_bw()
  {
      QImage image;
      image.load(fileModel-&gt;fileInfo(listView-&gt;currentIndex()).absoluteFilePath());
  
      QSize sizeImage = image.size();
      int width = sizeImage.width(), height = sizeImage.height();
  
      QRgb color;
      int value;
  
      for (int f1=0; f1&lt;width; f1++) {
          for (int f2=0; f2&lt;height; f2++) {
              color = image.pixel(f1, f2);
              image.setPixel(f1, f2, QColor((qRed(color) + qGreen(color) + qBlue(color))/3).rgb());
          }
      }
      sceneGraphics-&gt;clear();
      sceneGraphics-&gt;addPixmap(QPixmap::fromImage(image));
  }
  </code></pre>
  
  <p>I think the code should work, but there is a problem.</p>
  
  <p>The problem with this code is that I always get blue-black images insted black-white images. Do you know how to fix this.</p>
  
  <p>Thanks.</p>