I'm using VS2005, .NET Framework 2.0.
I'm drawing lines/rectangles/arrow etc. over a background image.
The background image might change it's colors so the lines/rectangles/arrow
I'm drawing will bled in the background and the user may not see it clear
enough.
I want draw the lines/rectangles/arrow so their color will very according to
the behind background image color.
Any idea how to do that?
--
Thanks
Sharon
You haven't given enough information about the problem you are trying
to solve to provide a very useful answer. It's unclear which part of
the described scenario you are asking about.
Can anything be assumed about the background or can it be an arbitrary
image?
Do you want the each of the foreground objects to be drawn with a
single color, or can the color of a single object vary (per pixel, per
segment, etc)?
Are you asking how to determine a complimentary foreground color given
a background color? Or do you already know the colors and you want to
know how to draw using those colors?
Chris
I'll try...
According to the background image change of colors I need the
lines/rectangles/arrow that I'm drawing to be clearly visible to the user
eye. So the color of the lines/rectangles/arrow must be change according to
the changes of the background colors.I believe that in order to do that there
is a XOR setting of the native GDI, I just haven't used it.
> Can anything be assumed about the background or can
> it be an arbitrary image?
The background is a 256 colors indexed bitmap. The bitmap palette can vary
according to the user GUI. So nothing can assumed about the background, it's
definitely an arbitrary image.
> Do you want the each of the foreground objects to be drawn
> with a single color, or can the color of a single object vary
> (per pixel, per segment, etc)?
I haven't thought whether each of the foreground objects should be drawn
with a single color, or can the color of a single object vary. I guess it
does not matter as long as all of it is clearly shown to the user eye.
> Are you asking how to determine a complimentary foreground
> color given a background color? Or do you already know the
> colors and you want to know how to draw using those colors?
I'm asking how to set the foreground color so it will have the most
emphasized color depending on the background color (like black foreground to
a white background).
Is there a way to do that using the .NET Framework 2.0 GDI Plus?
Or how can I do that in any other way?
--
Thanks
Sharon
Note: I'm using C# with .NET Framework 2.0.
--
Thanks
Sharon
Lines and the outlines of rectangles are drawn using the currently selected pen, in the
currently-selected pen mode. For example, to draw a line over an image using XOR, you
would do
HDC dc;
... initialize DC to the DC somehow...for example, obtaining it from the C# environment...
HPEN pen = CreatePen(PS_SOLID, 0, RGB(255, 255, 255));
SetROP2(dc, R2_XORPEN);
MoveToEx(dc, x0, y0, NULL);
LineTo(dc, x1, y1);
This XORs the color code 255, 255, 255 with the color currently present. If the
background is white, you get a black line. If the background is RGB(255, 0, 0) [red] you
get RGB(0, 255, 255) [cyan] for the line color. If the background is RGB(128, 128, 128) =
RGB(0x80, 0x80, 0x80) then the line is RGB(0x7F, 0x7F, 0x7F) (RGB(127, 127, 127) and it is
going to be hard to see. You can work it out for NOT and XORNOT, and compute a pen color
appropriate for your app.
Solid rectanges pose a different set of problems, and to get these to work, you would have
to draw them on an offscreen bitmap and use BitBlt with an appropriate code, such as
SRCINVERT or one of the many possible BitBlt codes (the enumeration of the parameter
values in the documentation is a subset of the total possible number of values, which is
much more extensive, but can only be expressed in hex). There are 256 possible codes for
BitBlt. Search for "ternary raster operations" in the MSDN for the complete list of codes
and how they combine the bits.
SetROP2 sets the binary ROP code
BitBlt uses ternary ROP codes
MaskBlt, PlgBlt and a few others use quaternary ROP codes
You can also use alpha-blending for solid figures.
joe