• 7502阅读
  • 6回复

如何获得窗口某点的颜色值 [复制链接]

上一主题 下一主题
离线noinfonofear
 

只看楼主 正序阅读 楼主  发表于: 2010-01-13
如何获得窗口某点的颜色值
如何获得QWidget指定点的颜色值?
谢谢!
离线孤※少
只看该作者 6楼 发表于: 2012-04-27
好像不能成功呀!
离线benbenmajia

只看该作者 5楼 发表于: 2010-01-16
受教
安然.....
离线noinfonofear

只看该作者 4楼 发表于: 2010-01-16
谢谢
离线yangfanxing
只看该作者 3楼 发表于: 2010-01-13
“获得pixmap后将它转换为QImage,用pixel取得一个点的颜色”
——————————————————————————————
LS最后一句~
PHPWind好恶心。。。不想看这种界面。。。
离线rep_1984
只看该作者 2楼 发表于: 2010-01-13
QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 ) [static]
Creates a pixmap and paints widget in it.
If the widget has any children, then they are also painted in the appropriate positions.

If you specify x, y, w or h, only the rectangle you specify is painted. The defaults are 0, 0 (top-left corner) and -1,-1 (which means the entire widget).

(If w is negative, the function copies everything to the right border of the window. If h is negative, the function copies everything to the bottom of the window.)

If widget is 0, or if the rectangle defined by x, y, the modified w and the modified h does not overlap the widget->rect(), this function will return a null QPixmap.

This function actually asks widget to paint itself (and its children to paint themselves). QPixmap::grabWindow() grabs pixels off the screen, which is a bit faster and picks up exactly what's on-screen. This function works by calling paintEvent() with painter redirection turned on. If there are overlaying windows, grabWindow() will see them, but not this function.

If there is overlap, it returns a pixmap of the size you want, containing a rendering of widget. If the rectangle you ask for is a superset of widget, the areas outside widget are covered with the widget's background.


See also grabWindow(), QPainter::redirect() and QWidget::paintEvent().

QPixmap QPixmap::grabWindow ( WId window, int x = 0, int y = 0, int w = -1, int h = -1 ) [static]
Grabs the contents of the window window and makes a pixmap out of it. Returns the pixmap.
The arguments (x, y) specify the offset in the window, whereas (w, h) specify the width and height of the area to be copied.

If w is negative, the function copies everything to the right border of the window. If h is negative, the function copies everything to the bottom of the window.

Note that grabWindows() grabs pixels from the screen, not from the window. If there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too.

Note also that the mouse cursor is generally not grabbed.

The reason we use a window identifier and not a QWidget is to enable grabbing of windows that are not part of the application, window system frames, and so on.

Warning: Grabbing an area outside the screen is not safe in general. This depends on the underlying window system.


See also grabWidget().

Example: qmag/qmag.cpp.


获得pixmap后将它转换为QImage,用pixel取得一个点的颜色
离线noinfonofear

只看该作者 1楼 发表于: 2010-01-13
我在QPainter类中没有找到相关的函数
快速回复
限100 字节
 
上一个 下一个