Skip to content
Snippets Groups Projects
Commit 3365476b authored by Rene's avatar Rene
Browse files

Erste Version des Programms

parents
Branches
No related tags found
No related merge requests found
x11-apps
dyncam.c 0 → 100644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
static int format = ZPixmap;
const char *program_name = "unknown_program";
Bool debug = False;
XImage *image;
Window window;
Display *display;
Screen screen;
int screenID;
XWindowAttributes win_info;
unsigned width, height;
int main (int argc, char **argv)
#define ARG argc
#define OPTION argv[0]
{
int argf= ARG;
#define NEXTOPT ++argv, --argf>0
//printf("%d\n", ARG);
Window dummywin; //Fragwürdig
int absx, absy; //Nicht in benutzung
GC mainGC;
while (NEXTOPT)
{
if (!strcmp(OPTION, "-test"))
{
NEXTOPT;
printf("%s\n", OPTION);
continue;
}
if (!strcmp(OPTION, "-debug"))
{
debug = True;
continue;
}
printf("wrong prameters!\n");
exit(0);
}
/* Debug ausgaben einschalten */
if (debug)
{
printf("Running in Debug mode!\n");
}
/* Display */
char *display_name = 0;
display = XOpenDisplay(display_name); //NULL Should refer to the root Window
if (display == NULL) {
fprintf (stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
exit(1);
}
screenID = XDefaultScreen(display);
if (debug)
{
printf("DEBUG: screen ID: %d\n", screenID);
}
window = RootWindow(display, screenID);
//display_name; //TODO
if(!XGetWindowAttributes(display, window, &win_info))
printf("Can't get target window attributes.");
width = win_info.width;
height = win_info.height;
if(debug) {
printf("DEBUG: Colormap is %ld bit\n", win_info.colormap);
printf("DEBUG: Window is %d x %d pixel\n", width,height);
}
if (!XTranslateCoordinates (display, window, RootWindow (display, screenID), 0, 0,
&absx, &absy, &dummywin)) {
fprintf (stderr,
"%s: unable to translate window coordinates (%d,%d)\n",
program_name, absx, absy);
exit (1);
} //fragwürdig
mainGC = XCreateGC(display, window, 0, 0);
image = XGetImage (display, window, 0,0,width,height,AllPlanes,format);
if (!image) {
fprintf (stderr, "%s: unable to get image at %dx%d+%d+%d\n",
program_name, width, height, 0, 0);
exit (1);
}
if(debug)
{
printf("DEBUG: Image data to String %s\n", image->data);
}
XPutImage(display, window, mainGC, image, 0, 0, 100, 100, 100, 100);
/* Pixels are getting printet by ff blue ff00 green ff00000 red */
if(debug) {
printf("The pixel in the middle has the value: %lx\n", image->f.get_pixel(image,width/2,height/2));
scanf("click to close");
}
image->f.destroy_image(image);
XDestroyWindow(display, window);
XCloseDisplay(display);
return 0;
}
test.xwd 0 → 100644
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment