[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

944.0. "Colors with the GC " by RABBET::FARRELL (Money, there is no substitute!) Wed Jun 14 1989 10:41

I have a program which changes the colors of some GC's, during run-time, with
the XChangeGC function.  This works no problem.

What I am looking for is, instead of a standard color, to produce a mesh-like
grey texture.  (i.e. 1 or 2 of every 4 pixels filled).  This would allow
the drawing under this edit to be seen (sort of like a screen door affect).

Is this possible?

Any help would be appreciated,

		$$$$ ted $$$$

T.RTitleUserPersonal
Name
DateLines
944.1XFillStippledHANNAH::MESSENGERBob MessengerWed Jun 14 1989 12:0811
Re: .0

Are you trying to change another application's GC behind its back?

You can write your pattern to a 1-plane-deep pixmap and use this pixmap
as a stipple pattern.  You need to set your fill_style to FillStippled.  Look
up FillStippled in whatever Xlib documentation you're using.  This should
work with lines, filled areas and text.

				-- Bob

944.2a little more...RABBET::FARRELLMoney, there is no substitute!Fri Jun 16 1989 10:4116
> Are you trying to change another application's GC behind its back?

This is a legitimate program (graphic editor) which has nothing to do with 
other's applications.

> You can write your pattern to a 1-plane-deep pixmap ..

Can you explain how you do this.  I can set the GC's stipple pattern and 
fill_style, but I used XCreateBitmapFromData and assigned a pixmap to it
(as I did for the icon picture), but I didn't get my pixel when I did 
a FillRectangle, I just got black.

thanks,

	$$$$ ted $$$$

944.3XCreateBitmapFromData should workHANNAH::MESSENGERBob MessengerFri Jun 16 1989 14:108
Re: .2

It's hard to say what you're doing wrong.  Does your picture get drawn
correctly when you *don't* specify a stipple pattern?  It would help if
you posted the relevant parts of your code.

				-- Bob

944.4...RABBET::FARRELLMoney, there is no substitute!Fri Jun 16 1989 16:0617
I am simply trying to have some objects (i.e. lines, filled circles, filled
rectangles, you know, shapes).

I want certain shapes to have this pattern instead of a color.  This would 
allow you to see through, let's say, a rectangle, and see a line under it.

The bitmap pattern I created (using decw$examples:bitmap.exe), was just a 
default size pattern with every fourth bit filled black.

If this doesn't help, I will post some code, but does this give you any ideas?

thanks for your responses,


	$$$$ ted $$$

944.5Need more info...HANNAH::MESSENGERBob MessengerFri Jun 16 1989 16:447
Re: .4

Well, you didn't answer my question about whether your code works with
fill_style == FillSolid.

				-- Bob

944.6ok, here's more... RABBET::FARRELLMoney, there is no substitute!Sat Jun 17 1989 14:4535
RE: .5  - Sorry Bob, I didn't see that part of your reply.

This is what the code looks like:

XGCValues gc_stuff;
Pixmap    greyPixel;
GC        context;

context->values.foreground=248;  /* let's make it red for now */
XCreateGC(...,&context);    /* Create the GC */

/* Use XGetAllocateNamedColor to get the LightGrey pixmap and load it into 
   greyPixel, this works fine. */

gc_stuff.fill_style = FillStipple;
gc_stuff.stipple = greyPixel;
gc_stuff.foreground = greyPixel;

XChangeGC(top_display,context,GCForeground | GCLineStyle | GCStipple,&gc_stuff);

/* Then draw something with the GC (fill rectangle) */

Well, the color changes to grey ok, but I definatly cannot see through it
like I wanted to.  (I can change to any color, no problem).

I also tried assigning foreground and stipple to a pixmap I created using
XCreateBitmapFromData, but that just came out black.

Is this enough info?  I am really stuck.

thanks (again),

	$$$$ ted $$$$

944.7Pixel != PixmapHANNAH::MESSENGERBob MessengerSat Jun 17 1989 18:1157
Re: .6

Ted,

You seem to have the mistaken impression that pixels and pixmaps are
interchangeable.

>XGCValues gc_stuff;
>Pixmap    greyPixel;
>GC        context;
>
>context->values.foreground=248;  /* let's make it red for now */

First, where did 248 come from, and second, why are you setting something in
the GC instead of the XGCValues?  Does this even work?

>XCreateGC(...,&context);    /* Create the GC */

Here "context" seems to be of type XGCValues.  If it's really a GC you should
have said context = XCreateGC(...,&gc_stuff).

>/* Use XGetAllocateNamedColor to get the LightGrey pixmap and load it into 
>   greyPixel, this works fine. */

Eh?  What's XGetAllocateNamedColor?  If you mean XAllocNamedColor, it returns
a Pixel, not a Pixmap.

>gc_stuff.fill_style = FillStipple;
>gc_stuff.stipple = greyPixel;
>gc_stuff.foreground = greyPixel;

If greyPixel is a Pixmap you can't set it in gc_stuff.foreground.  If it's a
Pixel you can't set it in gc_stuff.stipple.

>XChangeGC(top_display,context,GCForeground | GCLineStyle | GCStipple,&gc_stuff);

You wanted GCFillStyle, not GCLineStyle.

>/* Then draw something with the GC (fill rectangle) */
>
>Well, the color changes to grey ok, but I definatly cannot see through it
>like I wanted to.  (I can change to any color, no problem).

Probably because greyPixel is a Pixel, and can't be used as a stipple pattern.

>I also tried assigning foreground and stipple to a pixmap I created using
>XCreateBitmapFromData, but that just came out black.

You should set foreground to the *color* (Pixel) you want.  You should
set stipple to the *pattern* (Pixmap) you want.  You get pixels by calling
something like XAllocNamedColor and you get pixmaps by calling XCreatePixmap
and then writing to them as if they were a window.

Does this clear things up?

				-- Bob

944.8thanks...RABBET::FARRELLMoney, there is no substitute!Tue Jun 20 1989 11:2315
Thanks Bob.

That will be the last time I put in a code example from memory.  All the things
(but one) you mentioned, I did correctly in my real code.  I just messed them
up on my restoration to that reply.

The one that you did notice, was the GCLineStyle, instead of the GCFillStyle.

This *was* my problem.

Thank you very much for all your help,

		$$$$ ted $$$$