|
I would take the bitmap color, invert it and convert it to greyscale.
So, go 255-x on each of the red, green and blue components, then google for the algorithm to convert that color to greyscale ( my first image processing article has it, but I don't know it off the top of my head )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanx , I'll try that
btw your articles are great, I've learned a lot about colors from them
|
|
|
|
|
Hi,
I would compare the background brightness (Color.GetBrightness) with some middle
value, say 0.5f; if larger (=brighter), choose ForeColor=Color.Black,
else choose Color.White
|
|
|
|
|
Hi,
thats basicaly what I did and the problem is that some Colors are at constant Saturation, Luminacne values (Hue differs) were diffrent for human eye
e.g. :
try
constant Sat : 1f;
constant Lum : 0.5f;
=======
0.66 Hue - pure blue - very dark color, perfectly fits with white text color event if luminance is about 0.6f.
=======
0.5f Hue - cyan (something between blue and green)- very bright color, perfectly fits with black text color
even if luminance is about 0.4f.
|
|
|
|
|
Hi,
the way .NET calculates brightness gives about 0.5f for those colors
that have the three RGB components equal two one or two zero values
and two or one 255 values (that is red, green, blue, cyan, magenta, yellow).
For some of these colors you definitely want black foreground, for some it
is more or less undecided. I suggest you use Black for brightness (not luminance!)
above 0.4f or 0.45f
Alternatively you can calculate a fake brightness (in range 0-765) by
adding the RGB components of the background;
if that exceeds say 500 choose black, otherwise white.
This results in black foreground for cyan, magenta, yellow backgrounds (sum 510),
but white for red, green and blue (sum 255).
|
|
|
|
|
I know what's the diffrence between HSL and HSB, and I thought Color.GetBrightness() corresponds to HSL luminance. When creating HSL from a .NET Color,
i use :
this.Luminance = color.GetBrightness();
this.Saturation = color.GetSaturation();
this.Hue = color.GetHue();
so, is this incorrect approach? Ii thought it's just naming diffrence, I never tried to compare values when created color from HSL values if luminance and color.GetBrightness() match.
that fake brightness looks interesting, I'll try that, thanx
|
|
|
|
|
Hi,
I once looked into the brightness/luminance matter, and they are different;
HSL and HSB are not the same thing. Google and this article[^] may enlighten you on this.
Furthermore what .NET returns as Brightness did not match with my expectations;
but maybe I was biased by Java at that time, which IIRC returns the largest
of the three RGB values (which is strange by itself since then red and white
have the same brightness...)
|
|
|
|
|
Hi.
Anyway, fake brightness solved my problem, thanx a lot
|
|
|
|
|
Why C# does not support the multiple Inheritance
|
|
|
|
|
C# does not having more than one super class tats y we r using interfacing concept to overcome this.
|
|
|
|
|
Because it was easier not to, I suspect. You should use interfaces as a poor substitute. Interfaces are cool and useful, but they do not replace multiple inheritence.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't know... Stroustrup did it way back in the early 80s. Surely MS in the new millennium should have been able to do it? I think Chintan has the right answer below.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
let assume following class
class base1{}
class base2{}
class derive{} :base1,base2
Here if both base class has one common method say Method1().Now,during execution if derived class excess Method1(),then derived class will get confuse as from which base class i should get Method1(),therefore they were taken out from C# as well as from java.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
There also the case where 2 base classes inherit from the same base, you then inherit from those 2 classes.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
> Here if both base class has one common method say Method1().Now,during execution if derived class excess Method1(),then derived class will get confuse
Not really. This problem has already been solved at a same matter with multiple inheritance interfaces. It could be solved (IMHO with more willing).
For example:
class base1
{
void Method()
{
DoSomethingGood();
}
}
class base2
{
void Method()
{
DoSomethingVeryGood();
}
}
class derive : base1, base2
{
new void base1.Method()
{
DoSomethingBad();
}
new void base2.Method()
{
DoSomethingVeryBad();
}
}
|
|
|
|
|
It is VERY easy to abuse multiple inheritance and end up in "M.I. Hell" -- circular references, inheriting methods from each class that have the same name, destructors being called twice because two bases derive from the same base. All of this can be avoided with careful design, but I think it was a case of protecting the programmer from himself (herself).
-Phil
PS. I thought I'd save some time/code while programming a strategy/card game in C++ by having the card inherit from the actual unit so it could read it's stats and display it -- since the Card interface had the same accessor names for these stats I had to overload everything in the card in order to call the correct "versions" of these functions, and no time was saved.
|
|
|
|
|
|
Hi,
As a project for a friend I need to capture every album name from his website (long story).
Instead of going through page by page I thought it would be a good idea to scrape the html using regular expressions to extract the album names.
1) my first question is, is this the best way to go about it or can any body suggest a better method that I may not be aware of.
The reason I ask for a "better" method is because I've looked up regex for the first time and I'm pretty sure it will take me days to construct a useful expression (I find it hugely complex)
2) The layout of the html source is like this.
-------------------------------------------------------------------------------
<tr class="productListing-odd">
<td align="center" class="productListing-data"> <a href="http://eatmetalrecords.com/shop/product_info.php?cPath=41&products_id=2118"><img src="images/484_angra9.jpg" border="0" alt="ANGRA Angel's cry lp" title=" ANGRA Angel's cry lp " width="80" height="80"></a> </td>
<td class="productListing-data"> <a href="http://eatmetalrecords.com/shop/product_info.php?cPath=41&products_id=2118">ANGRA Angel's cry lp</a> </td>
<td align="right" class="productListing-data"> 33.00EUR </td>
<td align="center" class="productListing-data"><a href="http://eatmetalrecords.com/shop/index.php?cPath=41&sort=2a&action=buy_now&products_id=2118"><img src="includes/languages/english/images/buttons/button_buy_now.gif" border="0" alt="Buy Now" title=" Buy Now " width="60" height="16"></a> </td>
</tr>
-------------------------------------------------------------------------------
Based on this Should I first (and can I)
>Find all "image" tags
>Then find all "title" tags within the imgage tags
Any advice to get me up and going in some sort of direction is much appreciated
Thanks
DuB
|
|
|
|
|
Any help??
I had a look at the intro to regular expressions on this site. The examples are mainly on how to deal with bodies of text. there dosnt seem to be much on finding text within html tags?
Any known tutorials on this?
|
|
|
|
|
Take a look at the HTML Agility Pack[^]
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Scott's link looks like it might help you, but if you don't like that then Regex is probably the way to go. I'm not a Regex master so unfortunately I can't just spit out the pattern you need but something may already exist at the Regex Library[^]
|
|
|
|
|
I came across the agiltiy pack before but I couldnt figure out how to use it. theres not much documentation.
The regex library is great! found exactly what I was looking for.
Thanks for the replies
|
|
|
|
|
Hello...
Are there any easy ways to make label blinking ?
Instead of using Thread or Timer.
Thanks...
|
|
|
|
|
An animated gif file would be the easiest way probably.
|
|
|
|
|
Hello,
I don't think that there is an easier way than using a timer.
But maybe I'm wrong.
All the best,
Martin
|
|
|
|