|
Whahahahaha! I didnt even notice! Of course there is only 8 bits in a byte
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Well, technically, you did say "odd", and it IS indeed close
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: and it IS indeed close
Like NASA close
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Like Leppie said, dumping the whole screen as a buffer and transmitting will take a huge amount of memory. You should look at the following:
There is a pretty well standardised way of doing this with a protocol called remote frame buffer[^]. You should look into this protocol if you are writing a remote desktop program, as it will give a guide of good ways to do things (Even if you decide not to follow the protocol).
An alternative protocol used by MS is the remote desktop protocol[^]
The general area you are talking about is called Virtual network computing[^].
The general idea behind these protocols is to break the screen down into the smallest possible rectangle primitives and transmit them to be drawn on the client. A common way of reducing bandwidth is to only transmit what has changed between each refresh.
Ultra VNC[^] is an open source implementation of the RFB protocol. You can look at the source code for this to see how they are grabbing the screen.
Simon
|
|
|
|
|
I already know that the algorithm takes a large amount of memory, not to mention CPU. I've read the remote frame buffer documentation and that is why I'm looking for a way to "hook" the program to the video card. The biggest problem is the CPU consumption because the memory can be recycled: let's say 10 times per second I take a screenshot scan it and send only the changes. Still the CPU is at around 25-30% on a single core AMD.
What I want is to get only the changes(the updates) from the video buffer.
|
|
|
|
|
Read the ultra vnc source code. They obviously have a way of doing it that doesn't use that much cpu.
Simon
|
|
|
|
|
How are you accessing the image data? What do you use for screen capture?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: How are you accessing the image data? What do you use for screen capture?
Hi leppie, I'm using the Graphics class to get the screenshot (only 3 lines of code). Accessing the image data is very slow using safe code (GetPixel) so I'm using unsafe to access the memory.
|
|
|
|
|
|
Hey guys
I'm just wrote a simple struct to contain an int and two boolean values. Its is as follows..
struct NodeModuleLevelStruct
{
public NodeModuleLevelStruct(int ModuleID, bool IsActive, bool IsAdvanced)
{
moduleID = ModuleID;
moduleActive = IsActive;
level = IsAdvanced;
}
private bool moduleActive;
public bool IsActive
{
get { return moduleActive; }
set { moduleActive = value; }
}
private bool level;
public bool IsAdvanced
{
get { return level; }
set { level = value; }
}
private int moduleID;
public int ModuleID
{
get { return moduleID; }
set { moduleID = value; }
}
}
Now i need to query a NodeModuleLevelStruct[] using Linq so i have to inherit IEnumerable right?
so ive got
struct NodeModuleLevelStruct : IEnumerable<int>
...int cause i want to check if the given moduleID exists within that array
now the compiler is moaning that i havnt implemented System.Collections.Generic.IEnumerable<int>.GetEnumerator() or System.Collections.IEnumerable.GetEnumerator()
1) Am I on the right track here?
2) How do i implement those interfaces in my struct?
Thanks
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: Am I on the right track here?
No, you are doing it wrong
NodeModuleLevelStruct[] is already IEnumerable<NodeModuleLevelStruct> . So all you need to do is:
NodeModuleLevelStruct[] l = ...;
var q = from x in l
where x.ModuleID == 12345
select x;
Also, you should not use a struct in this case AFAICS.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: NodeModuleLevelStruct[] is already IEnumerable<nodemodulelevelstruct>
ah, i didnt know that... it works by just querying the NodeModuleLevelStruct[]
leppie wrote: Also, you should not use a struct in this case AFAICS.
what do u think i should use? And when should one use a struct anyway?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: what do u think i should use?
A class. Structs are mostly useless in .NET unless you require their special semantics. Example:
MyType[] list = new MyType[10];
Now define MyType as a class and see what the content is in 'list'. Now do the same but define MyType as struct.
An important point to notice is the way 'instances' are passed around. With structs, a copy of the value of the instance will be made, where classes will just send a reference to itself. So if used wrong, structs can become a big performance/memory killer. There are also other considerations, like modifying structs and things to keep in mind like boxing, that just blurs everything!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
thanks leppie
as always you rock
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
I slightly disagree with Leppie on this one.
I've seen it written many times that classes are easier to deal with and everyone says use them in C#.
If your example is really as simple as you've posted then seeing as each NodeModuleLevelStruct is going to be very small and is only using value types for properties/fields I'd be tempted to keep it as a struct. Small basic structs are easy to deal with, and if you want it to act like a reference type in a method you can always use the ref keyword. I find using structs very useful as I can be sure (so long as I've coded them properly) that my original instance is unchanged and if I want to change it, I can use ref or assign a copy's values to it.
It depends on how big it is, what it contains, and how you plan on using it.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: I slightly disagree with Leppie on this one.
What disagreement? Ok, it's ever so slight.
I think a good rule of thumb is to use structs only for small immutable types (the OP's is mutable, and hence can fall into the 'modification' trap).
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
leppie wrote: ever so slight
It's a good rule of thumb but one that can be ignored (carefuly) if the structure is only using integral types (as in the OP's) or other structs that only contain integral types. Take the Size struct as an example. It's not immutable, but a struct makes perfect sense and using it within your own struct would be good too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: Take the Size struct as an example. It's not immutable, but a struct makes perfect sense and using it within your own struct would be good too.
The Size struct is not a very good example, just because it's mutable.
If you need a type that is mutable, you should use a class, not a struct. It's so easy to accidentally change a copy of the struct instead of the struct.
As I am sure that you know, to safely change a property in a struct in an array you would have to:
NodeModuleLevelStruct temp;<br />
temp = theArray[42];<br />
temp.IsActive = true;<br />
theArray[42] = temp;
With a class, you can just do:
theArray[42].IsActive = true
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yeah - and that's exactly why I like to use them - only when appropriate of course.
I can work on the copy, make any changes I like and then just forget the whole thing if I don't want/need to commit them. If it's a class, to have that flexibility you have to implement some sort of cloning method and work on the clone, then you still have to remember to reassign.
I know where you're coming from, and agree to a point, but the blanket statement that if it's mutatble you should use a class, whilst it may prevent errors, isn't strictly true IMHO.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: I can work on the copy, make any changes I like and then just forget the whole thing if I don't want/need to commit them. If it's a class, to have that flexibility you have to implement some sort of cloning method and work on the clone, then you still have to remember to reassign.
I see your point, and that would work as long as it's only you who work with the code. If someone else has to take over your code, they can easily be fooled by this uncommon usage of structs.
A struct is a value type, and the semantics of a value type is to represent a single value of some kind. If you have several distinct values in a struct it doesn't behave as a value type any more, and you should use a class instead.
Also, a struct should not be larger than 16 bytes. A small struct can be copied using only a pair of machine instruction, while a large struct requires a loop to copy the memory area each time.
It's easier to use a struct for cloning instead of implementing proper cloning for a class, but you get worse performance.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: a large struct requires a loop to copy the memory area each time.
It's easier to use a struct for cloning instead of implementing proper cloning for a class, but you get worse performance.
I've read alot on this, especially today, and those two points I didn't come accross anywhere! Valid and noted.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I have all my data in MySQL as char data type in "en" locale.
That means all int and float and double type data are stored
as char data without thousand separator, but float and double data have
ofcourse with decimal (.) separator.
My question is : How can I display those data according to program's locale
setting. Since the data already in char type I could not find out a smouth
way to display the data returned from database accordingly. My program can change
the locale settings at run time according to user request.
By the way I use DataGridView for the display control on my win form.
Thanks,
Muharrem
|
|
|
|
|
Use one of the TryParse overloads for the data type that you need to display.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
hi
i have a code that does not response
dataGridview1.DataSource = dataset1;
i`m sore that dataset is fill
and when i use following code dbgrid creates as same record number as exist
in dataset but the value of rows in dbgrid are empty
dataGridview1.DataSource = dataset1.Tables[0];
|
|
|
|
|
Hi,
try to use the datagridview1.DataBind() method to finally bind the dataset to the datagridview.
Regards
Sebastian
|
|
|
|