bool OpenNI2CameraImpl::pollOne( OpenNI2Camera::FrameView& frame, int timeoutMS ) { frame.colorUpdated = false; frame.depthUpdated = false; frame.infraredUpdated = false; VideoStream* streams[] = { &m_colorStream, &m_depthStream, &m_infraredStream }; int readyIndex = -1; // Initialized to fail. Status rc = OpenNI::waitForAnyStream( streams, 3, &readyIndex, timeoutMS ); if( rc == STATUS_OK ) { if( readyIndex == 0 ) // color { return copyColor( frame ); } else if( readyIndex == 1 ) // depth { return copyDepth( frame ); } else if( readyIndex == 2 ) // infrared { return copyInfrared( frame ); } } return false; }
void genSpectrum(color colors[], int *numColors) { *numColors = 256 * 6; color c; c.r = 255; c.g = 0; c.b = 0; copyColor(&c, &colors[0]); for (int i=1; i<*numColors; i++) { if ( c.r == 255 && c.g < 255 && c.b == 0 ) c.g += 1; // Red to yellow else if ( c.r <= 255 && c.g == 255 && c.b == 0 && c.r != 0 ) c.r -= 1; // Yellow to green else if ( c.r == 0 && c.g == 255 && c.b < 255 ) c.b += 1; // Green to cyan else if ( c.r == 0 && c.g <= 255 && c.b == 255 && c.g != 0 ) c.g -= 1; // Cyan to blue else if ( c.r < 255 && c.g == 0 && c.b == 255 ) c.r += 1; // Blue to purple else if ( c.r == 255 && c.g == 0 && c.b <= 255 && c.b != 0 ) c.b -= 1; // Purple to red copyColor(&c, &colors[i]); } }
void ColorWidget::mouseReleaseEvent(QMouseEvent *event) { QWidget::mouseReleaseEvent(event); if (event->button() == Qt::LeftButton && m_buttonRectangle.contains(event->pos())) { QMenu menu(this); menu.addAction(tr("Select Color…"), this, SLOT(selectColor())); menu.addAction(tr("Copy Color"), this, SLOT(copyColor())); menu.addSeparator(); menu.addAction(ThemesManager::createIcon(QLatin1String("edit-clear")), tr("Clear"), this, SLOT(clear())); menu.exec(mapToGlobal(isRightToLeft() ? m_buttonRectangle.bottomRight() : m_buttonRectangle.bottomLeft())); } }
void updatePixel(sr_Screen * WS, unsigned short x, unsigned short y, sr_Color c) { unsigned long p = (x*WS->height+y); if(x<WS->width && y<WS->height) { if(!sameColor(WS->pixels[p/4].color[p%4],c)) { WS->pixels[p/4].update &= ~(3<<((p%4)*2)); WS->pixels[p/4].update |= 1<<((p%4)*2); copyColor(&(WS->pixels[p/4].color[p%4]),c); } else { if(!(WS->pixels[p/4].update & 3<<((p%4)*2)) && WS->pixels[p/4].update & 2<<((p%4)*2)) WS->pixels[p/4].update |= 3<<((p%4)*2); } } }
bool OpenNI2CameraImpl::pollColor( OpenNI2Camera::FrameView& frame, int timeoutMS ) { if( !m_colorStream.isValid() ) { return false; } VideoStream* streams[] = { &m_colorStream }; int readyIndex = -1; // Initialized to fail. Status rc = OpenNI::waitForAnyStream( streams, 1, &readyIndex, timeoutMS ); if( rc == STATUS_OK && readyIndex == 0 ) { return copyColor( frame ); } return false; }