[alt.msdos.programmer] graphic stencils

elrond@titan.tsd.arlut.utexas.edu (Brad Hlista) (11/28/89)

For those familiar with TurboC graphics, is there an easy way to place
images into graphics memory so that they will behave as stencils when 
many colors are being used.  If not, can I do something with the latch
registers that will preserve colors when shapes are written over existing
shapes...or do I need to go ahead and write new code to do stencils?
I ran into this problem recently and have not thought about it much...
hopefully, someone has a quick hack to do this.  Thanks for any help.

elrond@titan.tsd.arlut.utexas.edu

CMH117@PSUVM.BITNET (Charles Hannum) (11/28/89)

The easiest way I can think of to do this is the following:

Create a negative of the image in black-and-white.  Basically, the area that
you want to block out (to be overwritten by the actual image) should be black,
while the rest of the pattern should be white.  This pattern should be the
same size as the actual image.

Then, simply AND this with the background using putimage(), then OR the image
itself onto the screen, again using putimage().  The OR and AND functions are
a parameter to putimage().  I can't remember the format right off hand, but
you can look it up.

This method is used quite often in animation.  Its main feature is that it can
handle multiple colors.

If you using only a two-color system, of course, you can just OR the image on
to the screen.

If you need more help, I can email a sample program.

--
- Charles Martin Hannum II       "Klein bottle for sale ... inquire within."
    (That's Charles to you!)     "To life immortal!"
  cmh117@psuvm.{bitnet,psu.edu}  "No noozzzz izzz netzzzsnoozzzzz..."
  c9h@psuecl.{bitnet,psu.edu}    "Mem'ry, all alone in the moonlight ..."