Print screen

1. Print screen

Willian
ThePinkSharK

(usa Slackware)

Enviado em 03/03/2011 - 11:14h

Alguém tem alguma ideia de como eu posso tirar um print screen utilizando C?


  


2. Re: Print screen

André
andrezc

(usa Debian)

Enviado em 03/03/2011 - 12:50h

O C é uma linguagem de uso geral, portanto não sabe nada sobre printscreen.


3. Re: Print screen

Willian
ThePinkSharK

(usa Slackware)

Enviado em 03/03/2011 - 12:54h

Oh não me diga... sério? AGHR Eu ainda te... Um dia, um dia!
Eu ainda faço o Sr. compilar assembly!

---------------------------------

Existe alguma biblioteca que possa ser usada para fazer isso?


4. Oh não me diga... sério?

André
andrezc

(usa Debian)

Enviado em 03/03/2011 - 14:42h

Já que você sabe, porque perguntou? Nunca precisei fazer isso. Faça o seguinte, dê uma olhada no sourceforge, talvez você encontre algum projeto e até mesmo tira uma base nele.




5. Re: Print screen

JIMJR
jimjrivan

(usa Debian)

Enviado em 03/03/2011 - 15:23h

Cara num dá pra usar comando system e usar um snapshot?


6. Re: Print screen

Willian
ThePinkShark

(usa Slackware)

Enviado em 03/03/2011 - 16:40h

Em ambiente UNIX até dá, mas o programa precisa funcionar em UNIX, Linux e ... no outro...


7. Re: Print screen

Ricardo
Ricarod

(usa Ubuntu)

Enviado em 06/02/2017 - 19:14h

/*
	Grabs a screenshot of the root window.
	
	Usage	: ./scr_tool <display> <output file>
	Example	: ./scr_tool :0 /path/to/output.png

	Author: S Bozdag <selcuk.bozdag@gmail.com>
*/

#include <assert.h>
#include <stdio.h>
#include <cairo.h>
#include <cairo-xlib.h>
#include <X11/Xlib.h>

int main(int argc, char** argv) {
    Display *disp;
    Window root;
    cairo_surface_t *surface;
    int scr;
    /* The only checkpoint only concerns about the number of parameters, see "Usage" */
    if( argc != 3) {
    	fprintf(stderr, "Wrong number of parameters given \n");
    	fprintf(stderr, "Usage: ./ahenk_import <display> <output file> \n");
    	return 1;
    }
    /* try to connect to display, exit if it's NULL */
    disp = XOpenDisplay( argv[1] );
    if( disp == NULL ){
    	fprintf(stderr, "Given display cannot be found, exiting: %s\n" , argv[1]);
    	return 1;    	
    }
    scr = DefaultScreen(disp);
    root = DefaultRootWindow(disp);
    /* get the root surface on given display */
    surface = cairo_xlib_surface_create(disp, root, DefaultVisual(disp, scr),
                                                    DisplayWidth(disp, scr), 
                                                    DisplayHeight(disp, scr));
    /* right now, the tool only outputs PNG images */
    cairo_surface_write_to_png( surface, argv[2] );
    /* free the memory*/
    cairo_surface_destroy(surface);
    /* return with success */
    return 0;
} 

--------
compilei assim:
gcc `pkg-config --cflags --libs cairo` -o getImage getImage.c -lX11 -lcairo







Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts