[comp.sys.mac.programmer] CopyBits Help Needed!

rla20@DUTS.ccc.amdahl.com (03/15/91)

This is a follow-up to my posting of:
   ****HELP! Offscreen DrawPicture messes colors up.****
I am still having problems... but I am getting closer...
(for those who don't remember, I am trying to implement a Paste PICT to
an offscreen PixMap via DrawPicture)

I have recieved three (including the post) replys.  They suggested the
following:

1) Making sure the gDevice (during the Paste) is the same as the one
for the offscreen pixmap.
   --guess I should have done this from the start. I put in gDevice stuff
     & instead of totally random colors, now I got a picture with colors
     that are sometimes correct and sometimes pseudo-"inverted", read on..
2) See if the color matching routine was working.
   --tried my own color matching, but with no effect, CMgr matching
     works just the same as my matching.  The inverse table is sufficient.
3) use NewGWorld to set the offscreen stuff up.
   --well, maybe I should.  But, darn it, this *should* work without
     32-bit QD, etc.  It should work with the IM I-V stuff. Besides,
     I would have to get the THINK C libraries, etc...
5) make sure the forecolor & backcolor for the port are properly setup.
   --I did.  They are.  I THOUGHT.  Read on...

One thing I don't think I made clear in the last post was that the two
PixMaps (one on-screen, one off) have different Color Tables.  The
same colors are in both, but the order is different.
The one that is on screen is totally handled by CQD via SetPalette and
such... The one off-screen is set up by the file (GIF) that I read in.

So, what I have found out is that in the files with a CLUT that has
white as the first color (index=0) and black as the last color
(index=255) the DrawPicture seems to work.  Now, my testing is not
exhastive but this is what I have found out so far.

So, now my earlier question has been whittled down to a questions about
how CopyBits works--because the picture is created by CopyBits and
when it is drawn it calls CopyBits.

Here are my questions:

   1) How, EXACTLY (please no mumbo-jumbo hand-waving arguments here--
      I'm an EE/CS major I can take it) does CopyBits work when
      translating between different Color Maps?

   2) Why does CopyBits need Black/White to be the fore/background
      colors?  Do they have to be at index = (0/max)?

   3) Why didn't Apple put in a I-don't-care-what-the-destination-is-
      just-put-the-source-colors-thereCopyMode?  It seems this is what
      CopyBits is all about.  I just read in IM V about how CopyBits
      "fakes" srcCopy mode with addPin.  My question is WHY?  I would
      think most (but of course not all) apps don't care what the
      colors are at the destination.  Should I be zero-ing (or one-ing)
      out the destination rect before I CopyBits to it?

   4) What if the color table from the file does not HAVE black and
      white in it?  What is close enough to be useable?

Well, now it is your turn...please help, I am getting so close to
actually understanding CQD that I can almost taste it.

Mail responses are preferred, but post if you think all would benefit,
I will summarize all the responses that I get.

Thanks in advance,

Roger
--
> Roger Allen                    |  :~) "I always lie"                   <
> Amdahl Computer Development    |                                       <
> rla20@duts.ccc.amdahl.com      |  ;~( "I'm lying now"                  <

russotto@eng.umd.edu (Matthew T. Russotto) (03/18/91)

In article <faTe02cy052n01@JUTS.ccc.amdahl.com> rla20@DUTS.ccc.amdahl.com () writes:

>So, what I have found out is that in the files with a CLUT that has
>white as the first color (index=0) and black as the last color
>(index=255) the DrawPicture seems to work.  Now, my testing is not
>exhastive but this is what I have found out so far.

OK, then you are doing everything right.  Color tables must have white as the
first entry and black as the last.  If they don't, you will have to fix them
'by hand' so they do.
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
     .sig under construction, like the rest of this campus.
I mine 600 wells, and whaddo I get?  Another day older and deeper in debt!
	--- Saddam Hussein.

allenb@cs.uoregon.edu (Allen F. Brookes) (03/20/91)

I have had similar problems with copybits.  I want to copy images from
offscreen bitmap and not worry about what colors are in either CLUT.  My
solution was to do scanline by scanline block transfers to the video card.
This works fine for the old 8-bit video card but does not seem to work for
the 8-24 cards. Tech note 288 says that block transfers to Nubus cards are 
not supported but does not say it can't be done.  Does anyone know how I
can make block transfers work to the 8-24 card?

Allen Brookes