// **************************************************************************** // Method: QvisScribbleOpacityBar::setValues // // Purpose: // // // Programmer: Jeremy Meredith // Creation: January 31, 2001 // // **************************************************************************** void QvisScribbleOpacityBar::setValues(int x1, int y1, int x2, int y2) { if (x1==x2) { setValue(x2val(x2), y2val(y2)); return; } int xdiff = abs(x2 - x1) + 1; int step = (x1 < x2) ? 1 : -1; float slope = float(y2 - y1) / float (x2 - x1); for (int i=0; i<xdiff; i++) setValue(x2val(x1 + i*step), y2val(y1 + int(float(i)*slope*step))); }
// **************************************************************************** // Method: QvisScribbleOpacityBar::mousePressEvent // // Purpose: // // // Programmer: Jeremy Meredith // Creation: January 31, 2001 // // **************************************************************************** void QvisScribbleOpacityBar::mousePressEvent(QMouseEvent *e) { int _x = e->x(); int _y = e->y(); setValue(x2val(_x), y2val(_y)); lastx = _x; lasty = _y; mousedown = true; this->repaint(); }
void HSVRangeDisplay::updateImage() { m_width = width(); m_height = height(); //printf("HSVRangeDisplay::updateImage(): %d x %d\n", m_width, m_height); m_image = QImage(m_width, m_height, QImage::Format_RGB16); if (!m_width || !m_height) return; for (int y = 0; y < m_height; y++) { uint16 hue = y2hue(y); uint16 *dest = (uint16*) m_image.scanLine(y); for (int x = 0; x < m_width/2; x++) { *dest++ = HSV(hue, x2sat(x), 255).toPixel<Pixel565>().rgb; } for (int x = m_width/2; x < m_width; x++) { *dest++ = HSV(hue, 255, x2val(x)).toPixel<Pixel565>().rgb; } } }