Render well a scene



  • 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?



  • 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



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

    Thanks a lot



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


  • Qt Champions 2016

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



  • @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 :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.