draw label caption text as the inverse of the underlying form?
i have a form with a picture on it, and im lookinga t allowing the user to vary the picture. im deliberately choosing pictures of an average colour value, like sunsets and beaches; the whole picture is roughly belonging to one colour channel, so i can set the label caption to a complementing colour channel for it to stand out; light yellow on dark blue for example
but i'd like to know if it's possible, (even by drawing the text on a per-pixel basis?) to render text onto the image as the inverse of the colour underneath it.. hence a picture that was part red, part blue, would have text that was part cyan (on the red part) and part yellow (on the blue bits)
for exampl:
http://www.macromedia.com/support/au...el/Inverse.gif
how can i render font text onto the form so that the text is the inverse of the form's background image?
Re: draw label caption text as the inverse of the underlying form?
As you cannot use caption prowerty of labels with more than one forecolor,
I think you should draw directly on a pictureBox, using getpixel api to get
the aroundcolor (left-top-right-bottom pixels around your text), and setpixel
to draw...
Re: draw label caption text as the inverse of the underlying form?
If you are using Picture boxes then you can use a combination of Drawmode and pictureBox.Print method to achieve what you are looking for..
"Hint : Drawmode = Not Xor Pen"
Ever seen when a setup package created using PDWizard is executed and it shows a small progress window which displays what percentage of setup has been completed..
Open your VB IDE and open the Setup1 project (ideally present at "C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Setup1").. search for UpdateStatus function and you will see how it is done..
I leave the research up to u..:)
2 Attachment(s)
Re: draw label caption text as the inverse of the underlying form?
'*****
Great, vb_the_best! and you are really fast...
> UpdateStatus <
A pity I cannot rate you as have to spread around...
'****
A small simplified example...drag drop the "Hello" picture
around the bacKground one...(see picture for a preview. The
text is printed on a small picturebox...)
;)
Re: draw label caption text as the inverse of the underlying form?
mmmmhhhhh. it's close, but not quite there..
vb_da_best, i know why you suggest what you do; the text percentage is overpainted by a rectangular shape and as the shape passes over the text, it is inverted.. it cant be used for what i want thought, because it is the shape that is inverting rather than the text.. i want text to invert over a picture :/
cimperiali's method is close, but uses a hotspot per letter, and requires painting messages per character.. it would take a long time to write the code that types properly kerned text.. hrmm
ive slapped a background picture on my form, and drawn a solid Shape onto the form, then set the pen style to 6 - Invert (its the same as Not Xor) and the shape renders perfectly, the inverse of what is under it! however, i cannot find ANY way of making this work for anything other than a Shape, even though the help text indicates that DrawMode is applied to all objects. Ive tried Form1.Print "Some text" but the text is not drawn with inverse on, even though the form's drawmode is set to Invert
..
so on we quest...
1 Attachment(s)
Re: draw label caption text as the inverse of the underlying form?
ok.. this is what i figured out..
Drawmode works for all the Graphic operations (Line, Pset, etc) but does not work for Print (MSDN Says that)..:eek:
But now as I have learnt from my past experience that nothing is impossible, so here is what i did after some research and head scratching..:D
Took me some time to find out the exact method, and Cimp's sample was of great help.. And Cjard's ratings acted as motivators for me..
check out the sample attached (lot of APIs) and see if this will help..:wave:
Re: draw label caption text as the inverse of the underlying form?
that works great! im fiddling with the text rendering options to make it look a bit more pretty, but it's just what I want! Cimp; stick this in the faq thread! :)
Re: draw label caption text as the inverse of the underlying form?
>Cimp; stick this in the faq thread
Done.