Xref: utzoo comp.sys.amiga:26045 comp.sys.amiga.tech:2664
Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!gatech!purdue!decwrl!labrea!polya!ali
From: ali@polya.Stanford.EDU (Ali T. Ozer)
Newsgroups: comp.sys.amiga,comp.sys.amiga.tech
Subject: Re: MINTERM_SWAP?
Keywords: MINTERM graphics how
Message-ID: <5469@polya.Stanford.EDU>
Date: 4 Dec 88 17:45:58 GMT
References: <1576@nmtsun.nmt.edu>
Reply-To: aozer@NeXT.com
Organization: Stanford University
Lines: 36

In article <1576@nmtsun.nmt.edu> William Norris writes:
>Is there a simple way to swap two bitmaps without a third temporary bitmap?

Yes, but you need to do multiple blits. To swap A and B:

    A = A XOR B
    B = A XOR B
    A = A XOR B

Here's what I do in IFF2PCS (a puzzle program), when the user specifies
"show me the solution" (which causes what's on the screen to be swapped
with the actual picture, in some bitmap somewhere):

To swap:

   XORFromBMToBM (picbm, 0, 0,       winbm, picx, picy, picw, pich);
   XORFromBMToBM (winbm, picx, picy, picbm, 0, 0, picw, pich);
   XORFromBMToBM (picbm, 0, 0,       winbm, picx, picy, picw, pich);

/* Note that the in picbm, the picture is at 0,0, while in winbm, it's
** at picx, picy. The size is picw by pich.
*/

And the routine XORFromBMToBM is:

XORFromBMToBM (srcbm, srcx, srcy, destbm, destx, desty, sizex, sizey)
struct BitMap *srcbm, *destbm;
int srcx, srcy, destx, desty, sizex, sizey;
{
  BltBitMap (srcbm, srcx, srcy,
             destbm, destx, desty,
             sizex, sizey, 0x0060L /* mode */, 0x00ffL, NULL);
}

Make sure you coerce the args into longs if using Manx with 16 bit ints.

Ali Ozer