Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created October 23, 2013 22:56
Show Gist options
  • Save chrisallick/7128313 to your computer and use it in GitHub Desktop.
Save chrisallick/7128313 to your computer and use it in GitHub Desktop.
My dopest hack. I have no idea how to use openFrameworks, but this will get the pixels from your screen and then give you back the rgb value of wherever you are clicking...
void testApp::mousePressed(int x, int y, int button) {
receivedImage = FALSE;
ofImage theScreen; //declare variable
theScreen.grabScreen(0,0,1024,768); //grab at 0,0 a rect of 1024x768. Equivalent to loadPixels();
const ofPixelsRef pixels= theScreen.getPixelsRef();
ofLog() << (int)pixels.getColor(x,y).r << ", " << (int)pixels.getColor(x,y).g << ", " << (int)pixels.getColor(x,y).b;
ofxOscMessage m;
m.setAddress("/color");
m.addStringArg(ofToString((int)pixels.getColor(x,y).r) +","+ ofToString((int)pixels.getColor(x,y).g) +","+ ofToString((int)pixels.getColor(x,y).b));
sender.sendMessage(m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment