Organization of data for XImages

2003-02-15 Thread individual
Hi.

I haven't been able to find a specification of he layout of image data 
that XCreateImage() expects.

My natural instinct is to feed it data as follows. Each row in the 
following scheme represents 1 byte (in the case of a 16bpp image)

[ red Most Significant Byte ]
[ red Least Significant Byte ]
[ green Most Significant Byte ]
[ green Least Significant Byte ]
[ blue Most Significant Byte ]
[ blue Least Significant Byte ]

The above represents one pixel, the top-left hand corner pixel. Next 
pixel would be the one to its left, and so on, completing one scanline.

An alternate data layout would be to have first all the red data for a 
scanline, then all the green data and then all the blue data for the 
scanline.

Would someone please tell me which format XCreateImage() expects?


Thanks.

Paul

___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


[newbie] Help with XCreateImage

2003-02-14 Thread individual
Hi.


I have a rather basic question and I'm hoping that someone more 
experienced than I will be able to see what needs changing in this.

Objective: To display an image. I have the image in an array (type 
char), and each pixel is as follows:

[MSB_red] [LSB_red] [MSB_green] [LSB_green] [MSB_blue] [LSB_blue]

and so on. MSB stands for Most Significant Byte, and LSB for Least.

What follows are the relevant segments of the program:

   store = new char[3*width*height*bytes_per_pixel];

// store is loaded with the image, then

   display = XOpenDisplay (NULL);
   screen = DefaultScreen (display);
   depth = DefaultDepth (display, screen);
   window_attributes.border_pixel = BlackPixel (display, screen);
   window_attributes.background_pixel = BlackPixel (display, screen);
   window_attributes.override_redirect = 0;
   window_mask = CWBackPixel | CWBorderPixel;
   win = XCreateWindow (display, DefaultRootWindow (display), 0, 0,
width, height, 0, depth, InputOutput, 
CopyFromParent, window_mask,
window_attributes);
   x_image = XCreateImage (display, CopyFromParent, depth, ZPixmap, 0,
   store, width,
   height, 16, width * bytes_per_pixel * 3);
   image_gc = XCreateGC (display, win, 0, 0);
   XMapWindow (display, win);
   XSelectInput(display, win, ExposureMask | KeyPressMask | 
ButtonPressMask | StructureNotifyMask);
   while (1)
 {
XEvent x_event;
XNextEvent(display, x_event);
switch  (x_event.type)
{
case Expose:
   XPutImage (display, win, image_gc, x_image, 0, 0, 0, 
0, width, height);
   XFlush(display);
break;
case KeyPress:
if(XLookupKeysym(x_event.xkey, 0) == XK_q)
{
   delete [] store;
   image.close();
   return 0;
   exit(0);
}
   break;
}
 }
   return 0;
}

The image that is displayed can be seen at

http://ket.dyndns.org/xtest1.png

The proper image can be seen at:

http://ket.dyndns.org/xtest2.png

I would appreciate any wise words of wisdom.

Thanks

Paul

___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: A question about this list

2003-02-04 Thread Individual . .
On Tuesday, February 4, 2003, at 08:42 PM, Carsten Haitzler (The 
Rasterman) wrote:
main uses of xlib:
* writing window managers
* writing toolkits
* insane monkeys
* writing really small simple display programs that must require as 
little on
the host system as possible.

BINGO! Yes, that's it, exactly. What is not helping me is that I am not 
a programmer, I am a person that likes programming and then sets 
himself these tasks and tries to achieve them based upon tutorials and 
simple examples (reprehensible, I know!)
My first goal is to add a display function to a C++ class of mine that 
works with PNG images. It already relies on libpng, and I wanted to try 
and do it with xlib, instead of Gtk (more people will have X11 
installed than those who have Gtk).


Thanks for the comments.


Paul

___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel