This is now the whole event filter.
class PixelFilter(QtCore.QObject):
""" This is the Pixel Event Filter, which draws a label when Pixel
Information is activated.
MMB enables the UI and prints the according pixel information
inside of the RenderView.
"""
def eventFilter(self, source, event):
""" Creates the Pixel information event
@param source Object where event is installed on
@type: QtObject
@param event Event type
@type: QEvent
"""
if event.type() == QtCore.QEvent.MouseButtonPress:
if event.buttons() == QtCore.Qt.MidButton:
''' Creates design of pixel label'''
pixelLabel.setStyleSheet("QLabel {background: rgb(150,
150, 150);"
" border-style: inset;"
" border-width: 1px;"
"color: rgb(0, 0, 0);}")
pixelLabel.setAlignment(QtCore.Qt.AlignCenter)
self.img =
QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId(), 0, 0, -1,
-1).toImage()
return False
elif event.type() == QtCore.QEvent.MouseButtonRelease:
pixelLabel.hide()
source.removeEventFilter(self)
vrGlobalVariable.pixelInformation.setChecked(False)
return False
if event.type() == QtCore.QEvent.MouseMove:
if event.buttons() == QtCore.Qt.MidButton:
''' Shows Pixel Information label and updates when
mouse is moving'''
pixelLabel.show()
px = QtGui.QCursor.pos()
pixelLabel.setGeometry(px.x(), px.y() - 20, 120, 15)
c = self.img.pixel(px.x(), px.y())
color = QtGui.QColor(c).getRgbF()
pixelLabel.setText('R:%.2f G:%.2f B:%.2f \n' %
(color[0], color[1], color[2]))
return False
return QtCore.QObject.eventFilter(self, source, event)
On Friday, December 5, 2014 8:57:04 AM UTC+1, Marcus Ottosson wrote:
>
> Now I want to extend the feature, and use it with maya’s updated render
> view( float values)..but grabbing just grabs 8 bit..
>
> This is still me theorising, but remember back in Windows 95-98 when you
> could set your desktop to both resolution and color depth? Well, if you’d
> set the depth to 1-bit, the entire desktop would be black & white. Even the
> Maya Render View, and any image within it. I suspect that it is from this
> very same framebuffer that Qt grabs images from. Like the whole desktop is
> one big rendered image, and that image is limited to whichever bit-depth
> the window manager is set to render in. In the case of desktops today, this
> depth is typically 8-bit per channel which would explain why you’re only
> getting that depth when grabbing your images.
>
> What I am trying to do is getting float pixel values when hovering with
> the cursor above the image.
>
> As a solution, I think you could safely save out the image via the render
> view as Justin suggests, load that image and get the position and color of
> that instead of a grabbed image. You would subtract from the local
> coordinate of the Render View widget and apply it to the actual coordinates
> of the final image, taking Render View zoom into account. And you might
> probably want to delay the tooltip, as saving the image might take a second
> depending on its size, but tooltips typically take a second or two to show
> anyway so it should still work out.
>
> If you could show me what you’ve got so far I might be able to take a
> closer look.
>
>
> On 4 December 2014 at 23:09, Arvid Schneider <[email protected]
> <javascript:>> wrote:
>
>> Float is only supported in Maya 15 and above. And when saving the image
>> from the render view as exr its definitely float.
>> What I am trying to do is getting float pixel values when hovering with
>> the cursor above the image.
>>
>> What I have done so far is grabbing the whole screen image and saving it
>> as a qimage. Then getting the global mouse x and y to query the pixel rgb
>> value under the cursor. Its works pretty smooth..
>> Now I want to extend the feature, and use it with maya's updated render
>> view( float values)..but grabbing just grabs 8 bit..
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/af43fe28-6456-4611-b64d-ec2c09fa9941%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected] <javascript:>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/bf90388e-4f7e-404b-a690-d992c1843b99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.