[comp.sys.amiga.hardware] Help with the Blitter in C or in ASM!!!

slmt9@cc.usu.edu (06/20/91)

	This is another plea for help. 

	I need to be able to blit a piece of one picture onto another piece
of a a picture. Here the catch. I want to be able to see through the parts of
the picture that were black on the source of blit.
	In other words. If the source part of the blit was a ring with an open
center of the background color, palette 0, when it was blitted to the
destination only the NON-ZERO parts were copied. The result would be a ring
overlayed on the original destination picture. 

	Any help at all would be greatly appriciated. Also I can handle lots of
mail so please anyone with any ideas or help please let me know.

	Thanks in advance,
	Joshua
	SLMT9@cc.usu.edu

P.s.  Anu source in C or in ASM would be greatly appriciated. Thanks again.

chrisg@cbmvax.commodore.com (Chris Green) (06/20/91)

In article <1991Jun19.110117.48152@cc.usu.edu> slmt9@cc.usu.edu writes:
>
>	This is another plea for help. 
>
>	I need to be able to blit a piece of one picture onto another piece
>of a a picture. Here the catch. I want to be able to see through the parts of
>the picture that were black on the source of blit.
>	In other words. If the source part of the blit was a ring with an open
>center of the background color, palette 0, when it was blitted to the
>destination only the NON-ZERO parts were copied. The result would be a ring
>overlayed on the original destination picture. 
>
>	Any help at all would be greatly appriciated. Also I can handle lots of
>mail so please anyone with any ideas or help please let me know.
>
>	Thanks in advance,
>	Joshua
>	SLMT9@cc.usu.edu
>
>P.s.  Anu source in C or in ASM would be greatly appriciated. Thanks again.


	The amiga blitter (and operating system) have no blit that treats zero pixels
as transparent. The usual way of handling transparency is to create a 1-bitplane mask
for each shape, which has a 1 bit for each pixel that should be copied, and a
zero bit for each pixel that should be left alone. You can create such a mask from
a picture that is supposed to have transparent zero pixels by ORing together
all the bitplanes of the shape:

	struct BitMap src_bm, transparency_bm,src_tmp;
	PLANEPTR transparency_bits;
	if (transparency_bits=AllocRaster(src_width,src_height))
	{
		InitBitMap(&src_tmp,1,src_width,src_height);
		InitBitMap(&transparency_bm,1,src_width,src_height);
		transparency_bm.Planes[0]=transparency_bits;
		for(i=0;i<src_depth;i++)
		{
			src_tmp.Planes[0]=src_bm.Planes[i];
			BltBitMap(&src_tmp,0,0,&transparency_bm,0,0,src_width,src_height,
				(i)?0xee:0xc0,-1,0);
		}
	}

	At the end of this loop, transparency_bits will point to a plane that has 1's
where pixels should be copied, and zero where they shouldn't. This mask can be passed
to BltMaskBitMapRastPort, for instance. Since it is somewhat time consuming to
create this mask, you will probably want to keep it around for each shape, if you
can spare the RAM.

-- 
*-------------------------------------------*---------------------------*
|Chris Green - Graphics Software Engineer   - chrisg@commodore.COM      f
|                  Commodore-Amiga          - uunet!cbmvax!chrisg       n
|My opinions are my own, and do not         - killyouridolssonicdeath   o
|necessarily represent those of my employer.- itstheendoftheworld       r
*-------------------------------------------*---------------------------d