Gamma correction for display



  • I have a simple problem regarding final image look in QLabel. The image obviously lacks any gamma correction when displayed in QLabel and appears too dark. I wonder how to solve this. Shouldn't Qt somehow handle the color correction when I'm 'telling it' to view the image? I'm surely missing some crucial point.

    I'm creating QImage object from raw data, then I convert it to QPixmap and feed it to QLabel.

    		buffer = bytearray()
    		for y in xrange(height):
    			for x in xrange(width):
    				pixel = jpg_storage.GetPixel(x,y)
    				buffer.append(pixel.GetR()/256)
    				buffer.append(pixel.GetG()/256)
    				buffer.append(pixel.GetB()/256)
    
    		img = QtGui.QImage(buffer, width, height, QtGui.QImage.Format_RGB888)
    		label.setPixmap(QtGui.QPixmap.fromImage(img))
    

  • Moderators

    @krzysieklfc said in Gamma correction for display:

    Shouldn't Qt somehow handle the color correction when I'm 'telling it' to view the image?

    no! why should it?

    I don't quite understand why you are dividing by 256?
    Also whats the returning type of GetR()/GetG()/GetB()?


Log in to reply