void ofxFenster::setCursor(ofPixelsRef pixels, int hotX, int hotY) {
	//not compiling on windows right now
#if !defined(TARGET_WIN32)
	if(pixels.getNumChannels()<4) {
		ofLog(OF_LOG_WARNING, "setCursor ignored. please provide a pixelsRef with alpha channel.");
		return;
	}
	GHOST_TUns8 bitmap[pixels.getWidth()*pixels.getHeight()*3];
	GHOST_TUns8 mask[pixels.getWidth()*pixels.getHeight()];
	unsigned char* pixl = pixels.getPixels();
	int bmpCount = 0;
	int mskCount = 0;
	for(int i=0; i<pixels.getWidth()*pixels.getHeight()*4; i+=4) {
		for(int j=0; j<3; j++) {
			bitmap[bmpCount] = pixl[i+j];
			bmpCount++;
		}
		mask[mskCount] = pixl[i+3];
		mskCount++;
	}
	if(!win->setCustomCursorShape(bitmap, mask, pixels.getWidth(), pixels.getHeight(), hotX, hotY, 1, 0))
		ofLog(OF_LOG_WARNING, "setCursor: something went wrong. Maybe it's not supported on your system.");
#else
	ofLog(OF_LOG_WARNING, "setCursor: not supported on windows yet.");
#endif
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void scene02::applyLUT(ofPixelsRef pix){
	
    if (LUTloaded) {
		
		for(int y = 0; y < pix.getHeight(); y++){
			for(int x = 0; x < pix.getWidth(); x++){
				
				ofColor color = pix.getColor(x, y);
				
				int lutPos [3];
				for (int m=0; m<3; m++) {
					lutPos[m] = color[m] / 8;
					if (lutPos[m]==31) {
						lutPos[m]=30;
					}
				}
				
				ofVec3f start = lut[lutPos[0]][lutPos[1]][lutPos[2]];
				ofVec3f end = lut[lutPos[0]+1][lutPos[1]+1][lutPos[2]+1];
				
				for (int k=0; k<3; k++) {
					float amount = (color[k] % 8) / 8.0f;
					color[k]= (start[k] + amount * (end[k] - start[k])) * 255;
				}
				
				lutImg.setColor(x, y, color);
				
			}
		}
		
		lutImg.update();
	}
    
}
Exemplo n.º 3
0
void LaserGroup::setPixelsColors(ofPixelsRef pixels)
{
    for(auto laser: m_lasers)
    {
        const ofPoint& pos = laser->getPosition();
        ofColor color = pixels.getColor(pos.x*pixels.getWidth(), pos.y*pixels.getHeight());
        laser->setColor(color);
    }
    
    this->updateColor();
}
Exemplo n.º 4
0
void ofxAcv::apply(const ofPixelsRef src, ofPixelsRef dst) {
    if (src.getWidth() != dst.getWidth()
        || src.getHeight() != dst.getHeight()
        || src.getNumChannels() != dst.getNumChannels()) {
        ofLogNotice() << "reallocating dst";
        dst.allocate(src.getWidth(), src.getHeight(), src.getNumChannels());
    }
    int w = src.getWidth();
    int h = src.getHeight();
    int ch = src.getNumChannels();
    assert(ch <= curves.size());
    unsigned char* srcPixels = src.getPixels();
    unsigned char* dstPixels = dst.getPixels();
    
    for (int y=0; y<h; ++y) {
        for (int x=0; x<w; ++x) {
            for (int c=0; c<ch; ++c) {
                int idx = (y * w + x) * ch + c;
                dstPixels[idx] = curves[c][srcPixels[idx]];
            }
        }
    }
}
Exemplo n.º 5
0
void Video::learnBgColor(ofPixelsRef pixelSource) {
    int wXh = pixelSource.getWidth() * pixelSource.getHeight();
    int numPixels = wXh * pixelSource.getBytesPerPixel();
    int r,g,b;
    r=g=b=0;
    for(int i=0; i<numPixels; i+=pixelSource.getBytesPerPixel()) {
        r+=pixelSource[i];
        g+=pixelSource[i+1];
        b+=pixelSource[i+2];
    }
    r/=wXh;
    g/=wXh;
    b/=wXh;
    bgColor.set(r, g, b);
    removeBgFromAllFrames(); // TODO: Maybe remove this and make caller explicitly call this if they want to remove background?
}
void ofxCvCheckerboardPreview::setTestImage(ofPixelsRef pixels) {

    if(pixels.getImageType() != OF_IMAGE_GRAYSCALE) {
        ofLogError("ofxCvCheckerboardPreview -- must use grayscale image");
        return;
    }

    lock();
    testImage = pixels;
    if(!internalPixels.isAllocated()) {
        internalPixels.allocate(pixels.getWidth(), pixels.getHeight(), OF_IMAGE_GRAYSCALE);
    }
    newBoardToFind = true;
    boardFound = false;
    unlock();
}
//------------------------------------------------------------------------------
void ofxMatrixNetworkServer::sendFrame(const ofPixelsRef pixels)
{
	//for each connected client lets get the data being sent and lets print it to the screen
	for(unsigned int i = 0; i < (unsigned int)getLastID(); i++){
        
		if(isClientConnected(i) && tx_valid[i] == 2){
            tx_valid[i] = 1;
            
            int planecount = pixels.getNumChannels();
            int dimcount = 2; // only sending 2d matrices from of
            int dim[dimcount];
            dim[0]       = pixels.getWidth();
            dim[1]       = pixels.getHeight();
            int typeSize = pixels.getBytesPerChannel();
            int type     = JIT_MATRIX_TYPE_CHAR;
            
            makeMatrixHeader(planecount, typeSize, type, dim, dimcount);
            
            char *matrix = (char*)pixels.getPixels();
            
            
            //////SEND ONE MATRIX
            sendRawBytes(i, (char *)(&m_chunkHeader), sizeof(t_jit_net_packet_header));
            sendRawBytes(i, (char *)(&m_matrixHeader), sizeof(t_jit_net_packet_matrix));
            
            //DELETE THIS LINE
            //int packSize = SWAP32(m_matrixHeader.dimstride[dimcount-1])*SWAP32(m_matrixHeader.dim[dimcount-1]);
            
            //ofLog(OF_LOG_NOTICE, "send frame to client: " + ofToString(i));
            int vector = dim[0] * typeSize * planecount;
            for(int j = 0; j < dim[1]; j++){
                sendRawBytes(i, matrix + j * vector, vector);
            }
        }
    }
}
//------------------------------------------------------------------------------
void ofxJitterNetworkSender::sendFrame(const ofPixelsRef pixels)
{
    int planecount = pixels.getNumChannels();
    int dimcount = 2; // only sending 2d matrices from of
    int dim[dimcount];
    dim[0]       = pixels.getWidth();
    dim[1]       = pixels.getHeight();
    int typeSize = pixels.getBytesPerChannel();
    int type     = JIT_MATRIX_TYPE_CHAR;

    makeMatrixHeader(planecount, typeSize, type, dim, dimcount);

    char *matrix = (char*)pixels.getPixels();
    
    //////SEND ONE MATRIX
    sendRawBytes((char *)(&m_chunkHeader), sizeof(t_jit_net_packet_header));
    sendRawBytes((char *)(&m_matrixHeader), sizeof(t_jit_net_packet_matrix));
    
    int packSize = SWAP32(m_matrixHeader.dimstride[SWAP32(m_matrixHeader.dimcount)-1])
                * SWAP32(m_matrixHeader.dim[SWAP32(m_matrixHeader.dimcount)-1]);

    sendRawBytes(matrix, packSize);

}
Exemplo n.º 9
0
void ofxGreenscreen::setPixels(ofPixelsRef pixels) {
	setPixels(pixels.getPixels(), pixels.getWidth(), pixels.getHeight());
}
Exemplo n.º 10
0
void ofxGreenscreen::learnBgColor(ofPixelsRef pixelSource) {
	learnBgColor(pixelSource, 0, 0, pixelSource.getWidth(), pixelSource.getHeight());
}
Exemplo n.º 11
0
void ofxFenster::setIcon(ofPixelsRef pixels) {
	if(!win->setIcon(pixels.getPixels(), pixels.getWidth(), pixels.getHeight()))
		ofLog(OF_LOG_WARNING, "oops, looks like setIcon is not yet supported on your system");
}