[ LUGOS ] X programiranje

Gasper Fele gasper.fele na guest.arnes.si
Čet Okt 16 20:24:45 CEST 1997


Zivijo, spet jaz. A mi lahko kdo pove, zakaj tale program ne pokaze
slikice?

/*
  Copyright Gasper Fele-Zorz (gaspe.fele na guest.arnes.si)
  This program is being written for my own education only.
  Everyone is urged to help me, anyone who wants to use this code can do so.
  
*/

#include <X11/Xlib.h>
#include <stdio.h>
#include <unistd.h>
#include <X11/xpm.h>


Display *display;
int screen;
Window buto;
char **buffer;
Pixmap pict;
XImage *image;
char s;
char *name;
XpmAttributes xpmattr;
GC theGC;


void MyInit()
{
  display = XOpenDisplay(NULL);
  screen = DefaultScreen(display);
  buto = XCreateSimpleWindow(display, XRootWindow(display, screen), 1, 1, 200, 200, 4, 1,0);
  pict = XCreatePixmap(display, XRootWindow(display, screen), 40, 40, DefaultDepth(display, screen));
  theGC = XCreateGC(display, buto, 0, NULL);
  xpmattr.depth = DefaultDepth(display, screen);
  xpmattr.valuemask = XpmDepth;

/* enter the name of the pismap here */
  name = "/home/prog/prog/pixmaps/C.xpm";
  
/* Load the file */
  XpmReadFileToData(name, &buffer);
  XpmCreateImageFromData(display, buffer, &image, NULL, &xpmattr);
  XPutImage(display, pict, theGC, image, 0, 0, 0, 0, 100, 100);  
 
};



void DrawTest()
{
  XCopyArea(display, pict, buto, theGC, 1, 1, 100, 100, 1, 1);
  XFlush(display);
  XMapWindow(display, buto);
  XFlush(display);
  XRaiseWindow(display, buto);
  XCopyArea(display,XRootWindow(display, screen) , pict, theGC, 0, 0, 100, 100, 1, 1);
  XMapWindow(display, buto);
};



void main () {
  MyInit();
  DrawTest();
  scanf(&s);  // I know this is no the way I'm supposed to do this but I intend to study the events a bit later
  XFreePixmap(display, pict);
  XDestroyWindow(display, buto);  
  XCloseDisplay(display);  
}








Dodatne informacije o seznamu Starilist