[comp.sys.amiga] BltBitMap

baer@percival.UUCP (Ken Baer) (02/07/88)

< Line Eater Kibbles-n-Bits >

I have been having some trouble getting the BltBitMap() function to work
properly.  I am trying to do a simple copy from one bitmap to another
of the same size (both allocated in ChipRam).  The function returns 0,
which means that it hasn't copied any of the bitplanes.  The following
code should illustrate what I'm trying to do.  

struct BitMap *bitmap1, *oldbitmap1;
struct ViewPort vp1;
WORD blitnum;

....

blitnum = BltBitMap(bitmap1, 0, 0, oldbitmap1, 0, 0, vp1->DWidth, vp1->DHeight,
		0xc0, 0xff, NULL);
....

I have also tried this with a TempA allocated.  I have also inserted a
WaitBlit() and OwnBlitter(), DisownBlitter().  I must be making some blaring
error somewhere.  All I want to do is copy a full bitmap, nothing fancy.
Any suggestions or pointers :-) will be greatly appreciated.  Thanks in
Advance.
-- 
	-Ken Baer.  					 
   //   Amiga: The PC that CAN walk and chew gum at the same time.
 \X/    USENET - ...tektronix!reed!percival!baer   OR   baer@percival.UUCP
"The Few, The Proud, The Criminally Insane - Oberlin Computer Science" - me.

baer@percival.UUCP (Ken Baer) (02/08/88)

In article <1081@percival.UUCP> baer@percival.UUCP (Ken Baer) writes:
>struct ViewPort vp1;

Oops!  This was a typo.  This line should be:
struct ViewPort *vp1.

BTW, I'm using Manx 3.40a (with patches).  Thanks again in advance.
-- 
	-Ken Baer.  					 
   //   Amiga: The PC that CAN walk and chew gum at the same time.
 \X/    USENET - ...tektronix!reed!percival!baer   OR   baer@percival.UUCP
"The Few, The Proud, The Criminally Insane - Oberlin Computer Science" - me.

baer@percival.UUCP (02/10/88)

[LineEater diet pills  0 0 0 ]

I fixed the problem I was having with BltBitMap.  I screwed up the call to
InitBitMap().  I also didn't have all the parameters to BltBitMap() cast
to longs (shame on me!).  I also took out the OwnBlitter(), DisownBlitter()
stuff which was seemed to give some me problems.  Anyway, it's fixed, so if you
were going to post a reply to me plea for help, everything's hunky dorey
now, but thanks anyway.  Gee, I'm starting to feel like a real developer
now.  I'm sure I'll snap out of it soon :-).
	A least I'm not hacking in a vacuum.
-- 
	-Ken Baer.  					 
   //   Amiga: The PC that CAN walk and chew gum at the same time.
 \X/    USENET - ...tektronix!reed!percival!baer   OR   baer@percival.UUCP
"The Few, The Proud, The Criminally Insane - Oberlin Computer Science" - me.

bobb@tekfdi.TEK.COM (Robert Bales) (02/11/88)

In article <1081@percival.UUCP> baer@percival.UUCP (Ken Baer) writes:

>I have been having some trouble getting the BltBitMap() function to work
>properly. . . . The following code should illustrate what I'm trying to do.  

>struct BitMap *bitmap1, *oldbitmap1;
>struct ViewPort vp1;
>WORD blitnum;
>
>....
>
>blitnum = BltBitMap(bitmap1, 0, 0, oldbitmap1, 0, 0, vp1->DWidth, vp1->DHeight,
>		0xc0, 0xff, NULL);

Forgive me if this is an approximation and not an exact copy of the code, but
when using Manx (as Ken states in another message), *all* constants and other
integral values passed to Amiga functions must be *long* (0L).

   Bob Bales
   Tektronix, Inc.

I help Tektronix make their instruments. They don't help me make my opinions.

cks@radio.toronto.edu (Chris Siebenmann) (02/22/88)

 While this isn't your problem, everyone should be aware of a
BltBitMap() bug I stumbled across a while back. One of BltBitMap()'s
parameters is a temporary memory buffer for overlapping copies (tempA,
the last parameter). In 1.1, you had to allocate this yourself; in 1.2
the OS is supposed to do this for you.

 Well, it does. Of course, they never promised it would deallocate it
afterwards, and it doesn't. If you have lots of overlapping
BltBitMap()s, this can really eat chip memory quite fast, and in any
case it's eating precious chip memory. The easiest way of seeing this
bug in action is to write a program that does overlapping BltBitMap()s
in a loop (I threw out my example program, unfortunately) and watch
the chip memory total. Be sure to stick a delay in between each call,
or you won't be able to see the memory go down; the machine will just
crash.

-- 
	"I shall clasp my hands together and bow to the corners of the world."
			Number Ten Ox, "Bridge of Birds"
Chris Siebenmann		{allegra,mnetor,decvax,pyramid}!utgpu!radio!cks
cks@radio.toronto.edu	     or	...!utgpu!{chp!hak!ziebmef,ontmoh}!cks

ali@polya.STANFORD.EDU (Ali Ozer) (02/24/88)

In article <961@radio.toronto.edu> cks@radio.UUCP (Chris Siebenmann) writes:
> While this isn't your problem, everyone should be aware of a
>BltBitMap() bug I stumbled across a while back. One of BltBitMap()'s
>parameters is a temporary memory buffer for overlapping copies (tempA,
>the last parameter). In 1.1, you had to allocate this yourself; in 1.2
>the OS is supposed to do this for you. ...  But they never deallocate it
>afterwards ...

The same bug bit me while using The Director; I had text flying around
(different words on different bit planes, each bit plane blitting
in different direction; oh what power!) and I noticed that once in
a while my chip memory would go down in bursts of several K. Finally
I tracked it down to using the BLIT command to blit stuff directly to the
right --- that's the only time it'll lose stuff. So if you're a Director
user, be aware of this bug.

Ali Ozer, ali@polya.stanford.edu