Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef PICK_RGB_UTILS_H
Toshihiro Shimizu 890ddd
#define PICK_RGB_UTILS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qrect></qrect>
Toshihiro Shimizu 890ddd
#include <qrgb></qrgb>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//  Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QWidget;
Shinya Kitaoka 210a8a
class QOpenGLWidget;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Returns the average color displayed in a widget across the specified rect.
Shinya Kitaoka 120a6e
/*! This function reads the widget's frame buffer content on given rect, and
Shinya Kitaoka 120a6e
returns
Toshihiro Shimizu 890ddd
    a mean of its pixels. The widget's background color is assumed outside the
Toshihiro Shimizu 890ddd
    widget bounds.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
\warning Use this function only on plain widgets - in case your widget inherits
Shinya Kitaoka 120a6e
         QOpenGLWidget, invoke the overloaded function accepting a
Shinya Kitaoka 120a6e
QOpenGLWidget* type
Toshihiro Shimizu 890ddd
         instead.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
QRgb DVAPI pickRGB(QWidget *widget, const QRect &rect);
Shinya Kitaoka 120a6e
inline QRgb pickRGB(QWidget *widget, const QPoint &pos) {
Shinya Kitaoka 120a6e
  return pickRGB(widget, QRect(pos.x(), pos.y(), 1, 1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! Returns the average color displayed in a QOpenGLWidget instance across the
Shinya Kitaoka 120a6e
//! specified rect.
Shinya Kitaoka 120a6e
/*! This function reads the widget's front frame buffer on given rect, and
Shinya Kitaoka 120a6e
returns
Toshihiro Shimizu 890ddd
    a mean of its pixels.
Shinya Kitaoka 120a6e
Toshihiro Shimizu 890ddd
\warning Pixel colors are undefined outside the widget's geometry.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 210a8a
QRgb DVAPI pickRGB(QOpenGLWidget *widget, const QRect &rect);
Shinya Kitaoka 120a6e
inline QRgb pickRGB(QOpenGLWidget *widget, const QPoint &pos) {
Shinya Kitaoka 120a6e
  return pickRGB(widget, QRect(pos.x(), pos.y(), 1, 1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Returns the average color displayed on screen across the specified rect.
Toshihiro Shimizu 890ddd
/*! This function reads the screen's buffer on given rect, and returns
Toshihiro Shimizu 890ddd
    a mean of its pixels.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
\warning In general, grabbing an area outside the screen is not safe.
Toshihiro Shimizu 890ddd
         This depends on the underlying window system.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
QRgb DVAPI pickScreenRGB(const QRect &rect);
Shinya Kitaoka 120a6e
inline QRgb pickScreenRGB(const QPoint &pos) {
Shinya Kitaoka 120a6e
  return pickScreenRGB(QRect(pos.x(), pos.y(), 1, 1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // PICK_RGB_UTILS_H