Ask a Question related to Mac Programming, Design and Development.
-
Howard #1
How to use PaintRect and XOR with colors?
Hi..
I've been porting an app to the Mac, and have a problem with the use of
XOR and PaintRect to show specific colors.
I have a PICT resource copied from a 24-bit BMP file, which is a piano
keyboard. I want to show which key is being hit in an audio program, and to
do this in Windows I use an XOR drawing mode with an appropriate color.
That way, I can simply draw it once to show it as down, then draw it again
with the same code to show the key in its normal state again. However, on
the Mac, all I get is an inversion of the color from white-to-black or
vise-versa. Why??? I am using this code:
RGBColor c = { 0xffff, 0x0000, 0x0000 ); // red - should make white key turn
cyan!
RGBForeColor( &c );
PenNormal();
PenMode( patXor );
PaintRect(&myRect);
When I do a LineTo call, this method of setting the color and xor mode works
fine. But using PaintRect, all I get is black and white. Sure, the second
call returns the key to its normal state, but I want the (white) keys to
turn cyan when pressed. Why doesn't this work? Anyone know what I need to
do to make it work (short of saving the key state and drawing in a different
color depending onw hether it's up or down)?
Thanks,
Howard
Howard Guest
-
Colors change to differnt colors when printing
Whem I use Adobe Illustrator CS or Illustrator 10 a weird thing happens Example Ill be using red ,blue and a light blue color then Ill save the art... -
Bitmap image colors match FH colors?
If I import an image from Photoshop with a particular CMYK background color (as an example) will it match the same CMYK color selected in Freehand... -
Printout colors inconsistent with monitor colors
I'm new in the Photoshop world so I may have missed the explanations of my problems listed in the forum messages. I found Windows solutions but I... -
Why do the colors in the 'print preview' not match the colors on the desktop?
Using photoshop CS on a MAC OSX . Got the calibration OK, the print out pretty much matches the image on the desktop. And while I do plan to further... -
ANN: Want more colors?
Hi, I thought that some of you might be interested a new Design Aid product I'm offering for Fireworks and Flash users. It's called 10-Palette... -
David Phillip Oster #2
Re: How to use PaintRect and XOR with colors?
In article <bhqskp$bo0@dispatch.concentric.net>,
"Howard" <alicebt@hotmail.com> wrote:
PenNormal() resets the color. Move it BEFORE the RGBForeColor().> Hi..
>
> I've been porting an app to the Mac, and have a problem with the use of
> XOR and PaintRect to show specific colors.
>
> I have a PICT resource copied from a 24-bit BMP file, which is a piano
> keyboard. I want to show which key is being hit in an audio program, and to
> do this in Windows I use an XOR drawing mode with an appropriate color.
> That way, I can simply draw it once to show it as down, then draw it again
> with the same code to show the key in its normal state again. However, on
> the Mac, all I get is an inversion of the color from white-to-black or
> vise-versa. Why??? I am using this code:
>
> RGBColor c = { 0xffff, 0x0000, 0x0000 ); // red - should make white key turn
> cyan!
> RGBForeColor( &c );
> PenNormal();
> PenMode( patXor );
> PaintRect(&myRect);
>
> turn cyan when pressed. Why doesn't this work?
David Phillip Oster Guest
-
Mike Kluev #3
Re: How to use PaintRect and XOR with colors?
In Article bhqv6r$bnl@dispatch.concentric.net, Howard wrote:
It doesn't, although it resets penMode among other things.> "David Phillip Oster" <oster@ieee.org> wrote in message
> news:oster-7B777D.09223618082003@news.sf.sbcglobal.net...>> In article <bhqskp$bo0@dispatch.concentric.net>,
>> "Howard" <alicebt@hotmail.com> wrote:
>>
>> PenNormal() resets the color. Move it BEFORE the RGBForeColor().
It is very strange that it works with LineTo and doesn't work> Thanks, but that has no noticeable effect. It still only
> shows me black&white.
>
> Surely it can't be hard to simply xor a specific color with an existing
> background using PaintRect? It works fine with LineTo...what this
> difference?
with PaintRect: these two calls should behave the same in this
respect.
Do you observe this on Mac OS <= 9 with monitors set to 256 or
less colors? QuickDraw ignores color and inverts indices instead
of inverting color components when in indexed mode (8-bit per
pixel or less). E.g. if you draw red rectangle over white
background with xor mode it will become black in 8 bits.
The traditional way to do hiliting is:
RGBBackColor(&backgroundColor); // e.g. white if your keys are white
LMSetHiliteMode(LMGetHiliteMode() & ~(1L << hiliteBit));
InvertRect(&r);
// do the same to unhilite
-- OR --
RGBBackColor(&backgroundColor); // e.g. white if your keys are white
PenMode(hilite);
PaintRect(&r);
// restore PenMode, e.g. call PenNormal
// do the same to unhilite
That will respect the hilite color of user preference.
Although that will work pretty only if the area you are hiliting
is of solid color (that should match current background color).
If the hilited area contains shades of gray this works poor.
--
Mike Kluev
PS. Remove "-DELETE-." part of my e-mail address to reply.
Mike Kluev Guest
-
Howard #4
Re: How to use PaintRect and XOR with colors?
"Mike Kluev" <mike@objc-source.-DELETE-.org> wrote in message
news:BB671D8F.154B3%mike@objc-source.-DELETE-.org...The traditional way to do hiliting is:> In Article bhqv6r$bnl@dispatch.concentric.net, Howard wrote:Thanks, Mike! Works perfectly! :-D>
> RGBBackColor(&backgroundColor); // e.g. white if your keys are white
> LMSetHiliteMode(LMGetHiliteMode() & ~(1L << hiliteBit));
> InvertRect(&r);
> // do the same to unhilite
>
> -- OR --
>
> RGBBackColor(&backgroundColor); // e.g. white if your keys are white
> PenMode(hilite);
> PaintRect(&r);
> // restore PenMode, e.g. call PenNormal
> // do the same to unhilite
>
> That will respect the hilite color of user preference.
>
> Although that will work pretty only if the area you are hiliting
> is of solid color (that should match current background color).
> If the hilited area contains shades of gray this works poor.
>
> --
> Mike Kluev
-Howard
Howard Guest



Reply With Quote

