|
|
Thanks, I will take a look at it
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This is probably off-topic in that it doesn't relate directly to C#, but I'm hoping for some leeway...
I've done a lot of audio programming using both C# and C++. With both MDX (Managed DirectX) and the Win32 multimedia library, you can choose which device on your system to send waveform data to. For example, if you have several soundcards installed, you can choose which one plays your sounds.
I need to know the equivalent for video, i.e. I need to know what API I can use, hopefully with C#, that will allow me to choose from several video devices installed to send my video output to. MDX lets you play video files but they must be displayed in a window; there's no functionality, as far as I can see, to choose from various devices.
Any help is appreciated.
|
|
|
|
|
i need help on how 2 dimensional-discrete wavelet transform works for images because i have a class in 1 dimensional form
|
|
|
|
|
Good luck. Did something like that in a Master's course a few years ago. Do you have a specific question?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I see many programs do this, they read the screen using bitmap and screencapture and interpret the results. I got the code to capture screen using C#, and have converted to bitmap, but the only usable method is getPixel(int x, int y). For example here is some of my code:
Bitmap bt = (Bitmap)image1; //assume image1 is the screen capture output
String p = bt.getPixel(50, 100).toString(); which returns a string containing some information in RGB format,
now I do a if statement:
if(p == "some reference RGB")
return true;
else
return false;
Now as you can see this method takes a long time to first capture screen, convert to bitmap, read pixel of bitmap, compare it to reference, and return boolean. I was wondering if there was an easier way using API methods of the GDI32 dll file, that makes this easier and faster or whether its always slow.
How do "auto" programs work? I would like some information if anyone can help me please.
My source is always free, so support my applications.
MAx.
|
|
|
|
|
Try using unsafe code to scan the bitmap.
There's a series of articls about image processing, written by Christian Graus, here in CodeProject.
You can find the first one here[^].
Regards,
Shy.
|
|
|
|
|
Hello experts,
It is well known that when a string's length is already known or can be easily calculated, it is best to use StringBuilder instead of string .
But... How should one go about handling the following situation:
string alreadyAllocated = "ABCD";
string newString = "BLABLA" + alreadyAllocated; The way I see it, it's the same as doing:
string alreadyAllocated = "ABCD";
newString.Append("BLABLA");
newString.Append(alreadyAllocated); The reason I think it's the same is because to my understanding, when hardcoding the "BLABLA" string, memory is allocated for it anyway.
So the resulting pseudo code in both cases would be something like:
- Allocate memory for "BLABLA"
- Allocate memory for "BLABLA" + alreadyAllocated
- Copy both allocated strings to the new large location
Care to share your knowledge and opinions?
Thanks in advance,
Shy.
|
|
|
|
|
Try
System.Text.StringBuilder sb = new System.Text.StringBuilder ( "ABCD" ) ;
sb.Insert ( 0 , "BLABLA" , 1 ) ;
|
|
|
|
|
shyagam wrote: It is well known that when a string's length is already known or can be easily calculated, it is best to use StringBuilder instead of string.
Well known by whom?
The StringBuilder is best used when you don't know the length of the final string.
shyagam wrote: The reason I think it's the same is because to my understanding, when hardcoding the "BLABLA" string, memory is allocated for it anyway.
Yes, if you use a StringBuilder to just concatenate two strings, then there is no difference in how the memory is allocated.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
StringBuilder is very useful and efficient when it allows you to avoid a lot of
intermediate string objects. And it is best to create it with sufficient initial
capacity.
So instead of doing (silly example!):
string s="";
foreach (char c in "abcdefghijklmnopqrstuvwxyz") s=s+c;
Console.WriteLine(s);
which creates more than 20 string objects, you'd better do:
StringBuilder sb=new StringBuilder(100);
foreach (char c in "abcdefghijklmnopqrstuvwxyz") sb.Append(c);
string s=sb.ToString();
Console.WriteLine(s);
which only creates one StringBuilder and one string.
Since the capacity is sufficient, sb will never need an internal extend-and-copy
(as in good old Basic Redim).
StringBuilder will not give you a more efficient way to do a simple
string3=string1+string2 tho.
|
|
|
|
|
Hello every one!!
I made an application recently. Now I was tring to deploy that application by making its setup. After some of struggle I managed to make its setup. But there was a problem in it. I would like you people to help me through this problem. The problem is that I am using a DLL in that project. Now I want that whenever I install my application over another system the windows installer automatically copy that DLL in System and System32 Folders. Plz help me by assisting me to complete this task. I hope you people will help me in this regard. Anxiously waiting for Reply!!!!!!!!!!!!!
|
|
|
|
|
haseebbutt007 wrote: the windows installer automatically copy that DLL in System and System32 Folders
Why?? You don't need it in two places, only one. Any .DLL's your application uses should be placed in the applications folder under Program Files. The exception to this being an assembly that's registered in the GAC.
|
|
|
|
|
Thanks Sir for your kind reply. Can you please guide me about a link where I could find some tutorials about deployment in VS 2005. Waiting for your reply.
|
|
|
|
|
|
Obviously harder then typing it into a forum
-Larantz
|
|
|
|
|
OK, this is interesting, I think I've found a bug in the RegEx class in the .NET framework. Run the following as a simple console app...
using System.Text.RegularExpressions;
namespace RegExBug
{
class Program
{
static void Main(string[] args)
{
string emailPattern =
@"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
Regex emailTest = new Regex(emailPattern);
if (emailTest.IsMatch("sad.couple.skint.tired.fedup@ukgateway.n"))
{
return;
}
}
}
}
Now when it gets to the code 'emailTest.IsMatch' the application will hang. It doesn't throw an exception, just hangs there for ages (possible infinite loop bug in RegEx class??). Wrapping a try catch around it does nothing either.
Anyone know what could be going on?
|
|
|
|
|
I just tested this snippet and it appears you're right, the app hangs. Actually, it just takes a really long time thanks to the nested quantifiers.
I just did a search on Microsoft feedback center, is this the bug you're hitting? Complex Regex evaluation hangs[^]
Microsoft has this to say on the BCL team blog[^]:
Well, actually, it doesn't hang. It just takes a really really long time, and you haven't waited long enough for it to finish. One of the pitfalls with regular expression is that you can write expressions which don't perform very well. In particular, you can end up with expressions whose search time grows exponentially with the length of the search string. I get bugs reporting that Regex hangs about once a month, and it always turns out to be an exponentially slow expression. Here's a simplified example of one of them:
([a-z]+)*=
There are two things interesting about this expression. First, notice that it has two quantifiers nested within each other. The inner one is the + quantifier for the character class, and the outer one is the *. Second, it has a character (the equals char) that must be matched at the end of the result. In English terms, this expression can be explained as
1. match any character a-z, one or more times
2. match step #1 zero or more times
3. match an equals
What will happen is that Regex will breeze through step 1 and 2 only to find that it can't match in step 3. That forces it to backtrack and try to match the first two steps differently. The trouble is that there are a lot of different ways that steps 1 and 2 can match, and Regex needs to try every single one before it can determine that the expression does not match the string.
|
|
|
|
|
Which all of course leads onto the next question :-
What is the best email validating regex?
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
For which the correct answer is: There isn't one.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I agree. I've seen numerous ones all over the net and they all seem to have some kind of short coming. No silver bullet, cure all, I guess.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
|
dan neely wrote: It's gargantuan, about the size of a large paragraph.
Holy moly
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Scott Dorman wrote: There isn't one.
No, there is one, it's just really big:
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
That matches all RFC 2822 email addresses. However, if you want a regex that validates 99% of the email addresses out there and still performs well, this one[^] should work well.
*edit* dang smileys :-p
|
|
|
|
|
I forgot about www.regular-expressions.info[^], time to bookmark it
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|