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
}
示例#2
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]];
            }
        }
    }
}
//------------------------------------------------------------------------------
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);

}
void ofxGreenscreen::setPixels(ofPixelsRef pixels) {
	setPixels(pixels.getPixels(), pixels.getWidth(), pixels.getHeight());
}
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");
}