Hi guys,

I've wrote this piece of code that should make the black part of an image into a blue part. But the code doesn't change the black into the blue it never comes in the if test I think.

Could someone help me?

Qt Code:
  1. QImage background;
  2. QImage world(1500, 768, QImage::Format_RGB32);
  3. QSize sizeImage;
  4. int height, width;
  5. background.load("Background.png");
  6. world.fill(1);
  7.  
  8. QPainter painter(&world);
  9. sizeImage = background.size();
  10. width = sizeImage.width();
  11. height = sizeImage.height();
  12.  
  13. const QRgb black = 0;
  14. const QRgb blue = 255;
  15. for(int y = 0; y < height; y++) {
  16. for(int x = 0; x < width; x++) {
  17. if (background.pixel(x,y) == black) {
  18. background.setPixel(x,y,blue);
  19. }
  20. }
  21. }
  22.  
  23. painter.drawImage(0,0,background);
  24.  
  25. //adding new image to the graphicsScene
  26. QGraphicsPixmapItem item( QPixmap::fromImage(background));
  27. scene->addItem(&item);
  28.  
  29. QGraphicsView view(scene);
  30. view.show();
To copy to clipboard, switch view to plain text mode 

Kind regards,