Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Render well a scene

    General and Desktop
    3
    6
    914
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • AlvaroS
      AlvaroS last edited by

      Hello everyone:

      I have an scene where I load a .jpeg in it.
      And I add some lines in it as well.
      Now I would like to create a new .jpeg of the scene (with the new lines added)

      I do this:

      void MainWindow::on_line_to_map_Button_clicked()
      {
      
          QList<QGraphicsItem*>a;
          a = scene->items(); //Get items
      
          QPainter painter(&img);
          painter.setRenderHint(QPainter::NonCosmeticDefaultPen);
          
          painter.setPen(Qt::black);
      
          for (int i=0; i<a.size();i++){ //for each item:
              double XStart = line_at->line().x1();
              double XEnd = line_at->line().x2();
              double YStart = line_at->line().y1();
              double YEnd = line_at->line().y2();
      
              painter.drawLine(XStart, YStart, XEnd, YEnd);
      }
      

      The problem is that when I see the image created some pixels around the line are in grey... see this http://oi63.tinypic.com/jjpeza.jpg

      So how can I fix that?
      Maybe with another render way?

      kshegunov 1 Reply Last reply Reply Quote 0
      • V
        VRonin last edited by

        This looks a lot like it's a lossy compression problem of jpg rather than a problem of the painter. see https://www.youtube.com/watch?v=yBX8GFqt6GA

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        AlvaroS 1 Reply Last reply Reply Quote 0
        • AlvaroS
          AlvaroS @VRonin last edited by

          @VRonin And do you know how can I fix that problem?

          Thanks a lot

          1 Reply Last reply Reply Quote 0
          • V
            VRonin last edited by

            Try saving it in png and see if the problem solves itself

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            AlvaroS 1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @AlvaroS last edited by

              @AlvaroS
              As @VRonin hinted this is a color artifact produced by the way jpeg encodes (and compresses) the image data. To not have that, you need to choose a better suited file format, I suggest png here, which supports compression without loss.

              Kind regards.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 0
              • AlvaroS
                AlvaroS @VRonin last edited by

                @VRonin said:

                Try saving it in png and see if the problem solves itself

                @kshegunov said:

                @AlvaroS
                As @VRonin hinted this is a color artifact produced by the way jpeg encodes (and compresses) the image data. To not have that, you need to choose a better suited file format, I suggest png here, which supports compression without loss.

                Kind regards.

                Thanks a lot, png does not have that problem :)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post