LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-26-2003, 04:56 PM   #1
me01
LQ Newbie
 
Registered: Sep 2003
Posts: 1

Rep: Reputation: 0
Xlib question


Hi all,

I'm in the process of learning X, here's a basic program that should draw a pixmap on the display, but instead I get runtime error. I'd really appreciate any help...

================
#include <X11/Xlib.h>

Display *dpy;
XImage *img;
Visual *visual;
GC gc;
Window win;
XEvent report;

int win_width=500, win_height=500;
int img_width=16, img_height=1;

char myImage[] = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

int main() {

dpy = XOpenDisplay(NULL);
win = XCreateSimpleWindow(dpy, RootWindow(dpy,0), 1, 1, win_width, win_height, 0, WhitePixel (dpy,0), WhitePixel(dpy,0));
XMapWindow(dpy,win);
XSelectInput(dpy,win,ExposureMask | KeyPressMask | ButtonPressMask);
gc = XCreateGC(dpy, win, 0,0);
visual = DefaultVisual(dpy, DefaultScreen(dpy));

img = XCreateImage (dpy, visual, 8, ZPixmap, 0, myImage, img_width, img_height, 8, 0);

XPutImage(dpy, win, gc, img, 0, 0, win_width/2, win_height/2, img_width, img_height);

XFlush(dpy);

while(1) {
XNextEvent(dpy,&report);
switch (report.type) {
case Expose:
break;
case KeyPress:
break;
}
}
return(0);
}

==============
runtime error:

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 72 (X_PutImage)
Serial number of failed request: 11
Current serial number in output stream: 11

Who knows why?
Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified eyalkz Linux - Newbie 12 11-27-2018 01:30 PM
Xlib and images question SciYro Programming 2 06-14-2005 12:29 PM
Xlib: connection to ":0.0" refused by server Xlib: No protocol specified eyalkz Programming 1 03-02-2004 08:22 AM
Xlib question memory_leak Programming 0 12-05-2003 10:05 AM
Xlib-Windows Manager question amilici Programming 1 09-11-2003 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration