astellato / ofxSyphon

An OF add-on for using the Syphon framework.
Other
193 stars 57 forks source link

converting an ofTexture extracted from a ofxSyphonClient to an ofImage #40

Closed jeraman closed 6 years ago

jeraman commented 6 years ago

Hello,

I’m trying to convert an ofTexture—extracted from a ofxSyphonClient—to an ofImage as follows:

ofTexture sTexture(syphonClient.getTexture());
sTexture.draw(0, 0, ofGetWidth()/2, ofGetHeight());
ofPixels pixels;
sTexture.readToPixels(pixels);
ofImage sFrame;
sFrame.setFromPixels(pixels);
sFrame.draw(ofGetWidth()/2, 0, ofGetWidth()/2, ofGetHeight());

The problem is that sFrame is not being currently drawn (line 7). My sTexture, on the other hand, is drawn as expected (line 2). No errors are shown in the console.

The same code works fine if the sTexture is loaded from somewhere else (say a ofVideoPlayer) instead of a Syphon client.

Is this a bug or am I missing something?

bangnoise commented 6 years ago

Yep - this is a "feature" of the IOSurface which backs a Syphon texture. You will have to bind a same-sized FBO and draw the Syphon texture into that, and then download from the FBO's texture attachment.

jeraman commented 6 years ago

Thank you for the quick answer! Your solution works fine! ;)