[comp.sys.amiga.tech] Blitting

robertb@ulrik.uio.no (Robert Broughton) (06/07/90)

Is there an easy way to copy a particular plane (the first one, for example)
of one bit map to a different plane (the second one, for example) of another
bit map?

Why do I want to do this? My application uses a screen with four bit planes.
I am using another RastPort, set up using InitBitMap() and InitRastPort(),
to format text. When the text has been formatted, ClipBlit() is used to
move it into a window. This works. The only problem is that my "workarea"
RastPort also consists of four bit planes, and as a result, uses an outrageous
amount of chip memory. Now, one should not really need four bit planes for
formatting text; One should be sufficient. I could use
ClipBlit() to move a single bit plane to the first bit plane of the "window"
RastPort, if I set the RastPort's Mask to 0x01 (disable all bit planes
except the first one). Unfortunately, I'm using color 1 for background, and
color 15 for text. If I had chosen, a year ago, to use color 14 for
background, things would work great; Moving in ClipBlit()'ing in the first
bit plane would toggle the colors.

It's also occurred to me that I could use memcpy() to move data from one bit
plane to another, if the RastPorts were the same width; Alas, they're not.

Robert Broughton - robertb@ulrik.uio.no

jesup@cbmvax.commodore.com (Randell Jesup) (06/08/90)

In article <ROBERTB.90Jun7171514@ulrik.uio.no> robertb@ulrik.uio.no (Robert Broughton) writes:
>Is there an easy way to copy a particular plane (the first one, for example)
>of one bit map to a different plane (the second one, for example) of another
>bit map?
>
>Why do I want to do this? My application uses a screen with four bit planes.
>I am using another RastPort, set up using InitBitMap() and InitRastPort(),
>to format text. When the text has been formatted, ClipBlit() is used to
>move it into a window. This works. The only problem is that my "workarea"
>RastPort also consists of four bit planes, and as a result, uses an outrageous
>amount of chip memory. Now, one should not really need four bit planes for
>formatting text; One should be sufficient. I could use
>ClipBlit() to move a single bit plane to the first bit plane of the "window"
>RastPort, if I set the RastPort's Mask to 0x01 (disable all bit planes
>except the first one). Unfortunately, I'm using color 1 for background, and
>color 15 for text. If I had chosen, a year ago, to use color 14 for
>background, things would work great; Moving in ClipBlit()'ing in the first
>bit plane would toggle the colors.

	There is a way, which should be fairly usable.  Set up all the plane
ptrs in your bitmap structure to point to the same bitplane (and say it's 4
deep).  Then to make the pattern come out in color N, do 2 blits.  The first
blit should use a mask for the planes you want to be a '1' (from the binary of
N), and should use a Minterm like 0xC0 (straight copy).  The second blit
should cause those bits to go to 0 instead of 1 (look it up in the RKM,
I don't remember the minterm), and should specify a mask for the planes that
should be 0 in color N.  Note that you'll have to modify this slightly if
you're doing "cookie-cutter" blits (doesn't sound like it).

	It's a cute (but pretty standard) graphics trick.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"