Sceenshot ubuntu 16.04

Hi,

I can’t use any of the screenshot functions:
grabScreen,
ofSaveScreen,
ofSaveViewport
either in OF_WINDOW or OF_FULLSCREEN, i get 1/2 of width and 1/2 of height resolution .

I did a fresh install from the website (of_v0.9.8_linux64_release), on ubuntu 16.04, with packages updated, and this answer
installing OF dependencies with -hwe-16.04 packages, confirm Y/N ? N
(otherwise it doesn’t compile).

so there is my code, with this addon:

ofApp.h
"
#pragma once

#include “ofMain.h”
#include “ofxOpenCv.h”
#include “ofxJSON.h”

class ofApp : public ofBaseApp {
public:
void setup();
void draw();
void keyPressed(int key);
void loadJSONKinect();

	ofxJSONElement 		JSONKinect;
	ofEasyCam 			easyCam;

};"

main.cpp :
"#include “ofMain.h”
#include “ofApp.h”

//========================================================================
int main( ){

ofSetupOpenGL(1920,1080, OF_FULLSCREEN);			// <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new ofApp());

}
"

ofApp.cpp :
"
#include “ofApp.h”
//--------------------------------------------------------------
void ofApp::setup() {
loadJSONKinect();
}
void ofApp::draw() {
easyCam.begin();
int step = 0;
ofMesh mesh;
mesh.setMode(OF_PRIMITIVE_POINTS);
int lengthJson = JSONKinect[“data”].size();
while(step < lengthJson){
ofVec3f v;
v.x = (JSONKinect[“data”][step][“x”]).asInt();
v.y = (JSONKinect[“data”][step][“y”]).asInt();
v.z = (JSONKinect[“data”][step][“z”]).asInt();
int color = (JSONKinect[“data”][step][“c”]).asInt();
ofColor cPixel;
cPixel.r = (color & 0xff0000) >> 16;
cPixel.g = (color & 0x00ff00) >> 8;
cPixel.b = (color & 0x0000ff);
mesh.addVertex(v);
mesh.addColor(cPixel);
step += 1;
}
glPointSize(100);
ofPushMatrix();
ofScale(0.5, -0.5, -1);
ofTranslate(-1, -1, -1000);
ofEnableDepthTest();
mesh.drawVertices();
ofDisableDepthTest();
ofPopMatrix();
easyCam.end();
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if(key == ‘x’){
string name1 = “screenGrab.png”;
string name2 = “screenSave.png”;
string name3 = “screenView.png”;
ofImage screen;
ofRectangle view = ofGetCurrentViewport();
screen.allocate(1920, 1080, OF_IMAGE_COLOR);
screen.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
screen.save(name1);
ofSaveScreen(name2);
ofSaveViewport(name3);
cout << “saved”;
}
}
void ofApp::loadJSONKinect(){
string name = “f0.json”;
if(JSONKinect.open(name)){
cout << “opened the JSON file”;
}
} "

json file is :slight_smile:
" { “timeStamp” : 2458,
“data” :[{ “x” : -0,
“y” : -0,
“z” : 0,
“c” : 4462869
},
{ “x” : -105.131,
“y” : -172.715,
“z” : 1081,
“c” : 3277057
},
{ “x” : -101.376,
“y” : -172.715,
“z” : 1081,
“c” : 3411713
},
{ “x” : -98.2537,
“y” : -173.833,
“z” : 1088,
“c” : 3738646
},
{ “x” : -94.7352,
“y” : -174.313,
“z” : 1091,
“c” : 3082753
},
{ “x” : -91.2792,
“y” : -174.952,
“z” : 1095,
“c” : 1967105
},
{ “x” : -87.7156,
“y” : -175.431,
“z” : 1098,
“c” : 983300
}
]}"

the outputs I get is a dot in the bottom right corner of my screen, when it should be right in the center…

Workaround is to center my point cloud in the top left corner, but it’s not ideal…

Found a solution :smile:
In ofGLRenderer.cpp i changed OF_PIXELS_RGB to OF_PIXELS_RGBA inside saveScreen :
void ofGLRenderer::saveScreen(int x, int y, int w, int h, ofPixels & pixels){

int sh = getViewportHeight();


#ifndef TARGET_OPENGLES
ofBufferObject buffer;
      //here
//pixels.allocate(w, h, OF_PIXELS_RGB);
pixels.allocate(w, h, OF_PIXELS_RGBA);
buffer.allocate(pixels.size(),GL_STATIC_READ);
if(isVFlipped()){
	y = sh - y;
	y -= h; // top, bottom issues
}

buffer.bind(GL_PIXEL_PACK_BUFFER);
glReadPixels(x, y, w, h, ofGetGlFormat(pixels), GL_UNSIGNED_BYTE, 0); // read the memory....
buffer.unbind(GL_PIXEL_PACK_BUFFER);
unsigned char * p = buffer.map<unsigned char>(GL_READ_ONLY);
ofPixels src;
    //and here 
//src.setFromExternalPixels(p,w,h,OF_PIXELS_RGB);
src.setFromExternalPixels(p,w,h,OF_PIXELS_RGBA);
src.mirrorTo(pixels,true,false);
buffer.unmap();
//[...]
}

pixels are RGBA bydefault, (I guess? can someone confirm?).
Hope it helps.