[comp.sys.mac.programmer] Hilitemode and System 7.0

rdd@cactus.org (Robert Dorsett) (05/16/91)

A few weeks ago I posted about a really weird bug concerning hilitemode 
under 7.0.  I am still pulling my hair out about it.  I got no replies.

The bug manifests itself in two contexts:

1.  If the pen mode is set to hilite mode, and text is drawn, the text is
inverted.

2.  If a one-bit offscreen bitmap is copied to a window, with a transfer
mode of hilite mode, the bitmap is inverted.  

This is NOT supposed to happen.  The black bits should be assigned the hilite
color, THEN the operation applied against the target background.  Or so 
TN 163 would have one believe.

It looks a LOT to me like CopyBits was changed to support text hiliting one 
step earlier.  This would suggest a change in Apple's operational philosophy, 
to consider hilitemode as an exclusively text operation, and thus make 
Copybits copy bitmaps how text would appear hilited--inverted with the hilite 
color.

This problem did NOT occur under 6.0.7 or earlier.  It happens under 7.0
on IIci's, SE/30's, and IIcx's.  It does not happen under 7.0 and the IIsi.

If anyone has any ideas of what's wrong, I'd appreciate some insight.  Here's
a function which illustrates the problem:


void testcolor() {
    windowptr mywindow; 
    PaletteHandle mypalette;
    bitmap mybits;
    rect r;
    RGBColor mycolor;
    
    mywindow = GetNewCWindow(128,0L,-1L); /* generic window--no wctb's */
    setport(mywindow);
    showwindow(mywindow);

    /* the palette I used had seven arbitrary itmes.  0 = white, 1 = black,
           2-6 = anything */

    mypalette = GetNewPalette(128);
    ActivatePalette(mywindow);

    /* a generic bitmap-loader.  Finds a PICT resource with the specified
    ID (128), allocates space for it in the supplied bitmap, and shifts
    it such that the top left corner appears at the specified coordinates
    (10,10) */        
    LoadBits(128, &mybits,10,10);
    
    SetPalette(mywindow,mypalette,TRUE);
    
    
    PmBackColor(1);    /* black -- or any color */
    PmForeColor(0);    /* white -- or any color */
    r = mywindow->portRect;
    eraserect(&r);    /* shows up black */
    
    GetEntryColor(mypalette,6,&mycolor);    
    HiliteColor(&mycolor);
    
    r = mybits.bounds;

    /* and here the bloody thing is inverted */    
    copybits(&mybits,&mywindow->portBits,&r,&r,hilite,0L);

    
    while (!button()) {}
    FreeBitMap(&mybits);     /* free mybits.baseAddr */
    disposewindow(mywindow);
    }

An even easier approach would be:
    penmode(hilite);
    drawstring("\pInverted!");