Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Render well a scene
QtWS25 Last Chance

Render well a scene

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.1k Views
  • 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.
  • AlvaroSA Offline
    AlvaroSA Offline
    AlvaroS
    wrote on last edited by
    #1

    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?

    kshegunovK 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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

      AlvaroSA 1 Reply Last reply
      0
      • VRoninV VRonin

        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

        AlvaroSA Offline
        AlvaroSA Offline
        AlvaroS
        wrote on last edited by
        #3

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

        Thanks a lot

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          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

          AlvaroSA 1 Reply Last reply
          0
          • AlvaroSA AlvaroS

            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?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @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
            0
            • VRoninV VRonin

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

              AlvaroSA Offline
              AlvaroSA Offline
              AlvaroS
              wrote on last edited by
              #6

              @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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved