reimplement readQImage()
tested that call to repaint() is not needed
This commit is contained in:
parent
5d7dd101f2
commit
1b00d3448a
@ -535,20 +535,7 @@ class GLViewWidget(QtWidgets.QOpenGLWidget):
|
|||||||
"""
|
"""
|
||||||
Read the current buffer pixels out as a QImage.
|
Read the current buffer pixels out as a QImage.
|
||||||
"""
|
"""
|
||||||
w = self.deviceWidth()
|
return self.grabFramebuffer()
|
||||||
h = self.deviceHeight()
|
|
||||||
self.repaint()
|
|
||||||
pixels = np.empty((h, w, 4), dtype=np.ubyte)
|
|
||||||
pixels[:] = 128
|
|
||||||
pixels[...,0] = 50
|
|
||||||
pixels[...,3] = 255
|
|
||||||
|
|
||||||
glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels)
|
|
||||||
|
|
||||||
pixels = pixels[::-1].copy() # flip vertical
|
|
||||||
|
|
||||||
qimg = fn.ndarray_to_qimage(pixels, QtGui.QImage.Format.Format_RGBA8888)
|
|
||||||
return qimg
|
|
||||||
|
|
||||||
def renderToArray(self, size, format=GL_BGRA, type=GL_UNSIGNED_BYTE, textureSize=1024, padding=256):
|
def renderToArray(self, size, format=GL_BGRA, type=GL_UNSIGNED_BYTE, textureSize=1024, padding=256):
|
||||||
w,h = map(int, size)
|
w,h = map(int, size)
|
||||||
|
Loading…
Reference in New Issue
Block a user