Hi there,
My app is console-based (uses /opt/vc API.)
How can I make screenshots if I do not have XWindow running?
Either a command line utility, or an API would work for me.
Thanks,
Bram
Re: screenshot without XWindow running?
Easiest way is to use something like Putty on Windows laptop ssh into the pi and take a screen shot of the Putty session (ALT+Print Screen) same goes with Mac but different client and not sure what the key combo is for screen shot of just a Window and not the whole desktop. This assumes your program can run and output in an ssh session
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
Re: screenshot without XWindow running?
Or just Print Screen paste into a graphics package and crop. 

Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek 
If you find a solution please post it in the wiki the forum dies too quick

If you find a solution please post it in the wiki the forum dies too quick
Re: screenshot without XWindow running?
I'm pretty sure that the suggestions offered work only if X is running.
So in the end I just decided to add custom code to my app using glReadPixels()
In case someone else needs it. This writes out a dump, albeit top-bottom flipped.
Bram
So in the end I just decided to add custom code to my app using glReadPixels()
In case someone else needs it. This writes out a dump, albeit top-bottom flipped.
Code: Select all
const char* dumpScreen( void )
{
static int cnt=0;
const int w = state->screen_width;
const int h = state->screen_height;
const int sz = w*h;
GLubyte *buffer = (GLubyte *) malloc(4*sz);
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
static char fname[128];
snprintf( fname, 128, "/tmp/dump%02d.ppm", cnt );
FILE* f = fopen( fname, "wb" );
fprintf( f, "P6\n%d %d\n255\n", w, h );
fwrite( buffer, sz*4, 1, f );
fclose( f );
free(buffer);
printf( "dumped screen to '%s'\n", fname );
cnt++;
return fname;
}
Re: screenshot without XWindow running?
Quick web search for "linux console screen dump" found:
http://www.tldp.org/HOWTO/Keyboard-and- ... TO-20.html
However, you either need to be root or use sudo.
Although, I typically just ssh from Ubuntu into the Pi and use the mouse to highlight, then right click and "copy".
http://www.tldp.org/HOWTO/Keyboard-and- ... TO-20.html
However, you either need to be root or use sudo.
Although, I typically just ssh from Ubuntu into the Pi and use the mouse to highlight, then right click and "copy".
Re: screenshot without XWindow running?
@efflandt I am not trying to copy the text on the console.
I am trying to copy the graphics that was rendered on the console without XWindow being involved.
I am trying to copy the graphics that was rendered on the console without XWindow being involved.
Re: screenshot without XWindow running?
I don't know of a way to do this unless you use something like VNC to runn in a window on a PC but thats going to raise it's own issues.
There is one method thats been used on the forum and thats take a photograph of your screen with a digital camera.
This is non invasive and onece the picture is a jpeg you can do whatever you want with it.
There is one method thats been used on the forum and thats take a photograph of your screen with a digital camera.
This is non invasive and onece the picture is a jpeg you can do whatever you want with it.

Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek 
If you find a solution please post it in the wiki the forum dies too quick

If you find a solution please post it in the wiki the forum dies too quick
Re: screenshot without XWindow running?
VNC, X forwarding etc. only work if X started - there is no way to get to low-level graphics through Putty etc.
There are however loads of tools to capture the Linux framebuffer: fbcat, scrot, ... and there is always the quick-and-dirty way using 'cat /dev/fb0 >mycapture.raw' (if you don't have the aforementioned tools or do not want to install - or if you use 8 bit mode and the tools fail due to the bcm2708 fb driver not supporting GETPALETTE) - this gives you a raw byte dump of the fb (16 bit 5:6.5 by default) then import into IrfanView (with plugins installed) or similar.
Not 100% sure if the OpenGLES etc rendered stuff is available in the framebuffer though - haven't yet checked...
Dispmanx has it's own dump method vc_dispmanx_snapshot.
There are however loads of tools to capture the Linux framebuffer: fbcat, scrot, ... and there is always the quick-and-dirty way using 'cat /dev/fb0 >mycapture.raw' (if you don't have the aforementioned tools or do not want to install - or if you use 8 bit mode and the tools fail due to the bcm2708 fb driver not supporting GETPALETTE) - this gives you a raw byte dump of the fb (16 bit 5:6.5 by default) then import into IrfanView (with plugins installed) or similar.
Not 100% sure if the OpenGLES etc rendered stuff is available in the framebuffer though - haven't yet checked...
Dispmanx has it's own dump method vc_dispmanx_snapshot.
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
Re: screenshot without XWindow running?
Excellent info, -rst-, just what I was looking for.
Thank you.
Bram
Thank you.
Bram
Re: screenshot without XWindow running?
Well... now checked this and (of course) none of the HW accelerated stuff goes through the framebuffer. As said, dispmanx has it's own screenshot/dump function - I assume EGL may have one as well, or then you have to do your own like stolk did.-rst- wrote:Not 100% sure if the OpenGLES etc rendered stuff is available in the framebuffer though - haven't yet checked...
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'
- hanzelpeter
- Posts: 75
- Joined: Mon Jul 09, 2012 11:56 am
Re: screenshot without XWindow running?
Hello.
I have tried dispmanx_snapshot and it looks like it is working.
Here is code (main.c)
I have currently no monitor attached to PI, but tried hello_pi examples and shopshots looks ok.
I have tried dispmanx_snapshot and it looks like it is working.
Here is code (main.c)
Code: Select all
// A simple demo using dispmanx to display get screenshot
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <unistd.h>
#include <sys/time.h>
#include "bcm_host.h"
int main(void)
{
DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_MODEINFO_T info;
DISPMANX_RESOURCE_HANDLE_T resource;
VC_IMAGE_TYPE_T type = VC_IMAGE_RGB888;
VC_IMAGE_TRANSFORM_T transform = 0;
VC_RECT_T rect;
void *image;
uint32_t vc_image_ptr;
int ret;
uint32_t screen = 0;
bcm_host_init();
printf("Open display[%i]...\n", screen );
display = vc_dispmanx_display_open( screen );
ret = vc_dispmanx_display_get_info(display, &info);
assert(ret == 0);
printf( "Display is %d x %d\n", info.width, info.height );
image = calloc( 1, info.width * 3 * info.height );
assert(image);
resource = vc_dispmanx_resource_create( type,
info.width,
info.height,
&vc_image_ptr );
vc_dispmanx_snapshot(display, resource, transform);
vc_dispmanx_rect_set(&rect, 0, 0, info.width, info.height);
vc_dispmanx_resource_read_data(resource, &rect, image, info.width*3);
FILE *fp = fopen("out.ppm", "wb");
fprintf(fp, "P6\n%d %d\n255\n", info.width, info.height);
fwrite(image, info.width*3*info.height, 1, fp);
fclose(fp);
ret = vc_dispmanx_resource_delete( resource );
assert( ret == 0 );
ret = vc_dispmanx_display_close(display );
assert( ret == 0 );
return 0;
}
Re: screenshot without XWindow running?
Hello
this code work in horizontal display, but freeze if the display is rotate
this code work in horizontal display, but freeze if the display is rotate
