|
There's always the edit button
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Hello. I want to write a vnc like program in C# and the biggest problem, I think, is capturing the screen and sending the screen image. I tried transforming the screen bitmap to a bytes array and compress it with GZipStream, but the result is ~44KB so I can't send this over the network.
I have 2 questions:
1. Do you know of a way to capture only the changes in the screen and not the entire desktop?
2. Do you know of an algorithm that scans an image and returns only the changes efficiently, size wise?
Any ideas will be appreciated.
Thank you in advance
|
|
|
|
|
Im not sure about finding which parts of the screen have changed, but what you can do to help with the filesize is to lower the image from 24-bit down to 16-bit, maybe change it into a PNG (i like PNG's)
That should help with filesize. Hang on while i check the size of a 1650*1080 bitmap compared to the same PNG.
EDIT: Hold up, there is no 16-bit. I really need to go to bed now
Anyway, 24-bit bitmap of my screen is over 5MB, into gzip that gave 168KB
A 24-bit PNG was about 220KB, gzip is er... 219KB
8-Bit BMP 1.68, gzip 64KB
8-Bit PNG 80KB, GZip 79KB
So, apparantly, the smalles size you can acheive is to Gzip an 8-Bit BMP.
I just thought. If you disect your screen into perhaps 16 sections, then compare the bytes of the old image with those of the new image for each of the sections, then you can see if something has changed. If you find one of the sections is different than it was previously, you can send that area of the screen along with whatever section it belongs to.
The only problem is, if your comparing the binary data of each section, if just one pixel where to change you'd end up sending the whole section, rather than just ignoring it. Well, anyway, sleep now.
My current favourite word is: Bacon!
-SK Genius
modified on Friday, April 11, 2008 9:58 PM
|
|
|
|
|
That's a good idea and to tell you the truth I tried scanning the entire image to find coordinates of the first pixel changed and the last one (from left to right and top to bottom). This gave me a 44KB on average to send (only changes). This of course with a 32 bit bitmap. Now I'm working on an algorithm to divide the bitmap into rectangulars of the same color (pixel value) and send only the coord of the top-left pixel, the rectabngular size and pixel value. Maybe you know a similar algorithm?
Thank you very much for your reply SK Genius.
|
|
|
|
|
I am using a browser object to view PDFs in my c# code:
{
wbBrowsePDF.Navigating += new WebBrowserNavigatingEventHandler(wbBrowsePDF_Navigating);
wbBrowsePDF.Visible = true;
wbBrowsePDF.Navigate(strFileName);
}
private void wbBrowsePDF_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
System.Windows.Forms.HtmlDocument document =
this.wbBrowsePDF.Document;
}
it works just fine and then I use:
{
wbBrowsePDF.Stop();
wbBrowsePDF.Navigate("about:blank");
wbBrowsePDF.Dispose();
}
to close the document.
Problem is that the acrobat reader (AcroRd32.exe stays open and must be killed using Task Manager.
Could anyone please suggest any solution?
Thanks.
|
|
|
|
|
What version of Acrobat Reader is installed? I vaguely remember a similar issue with version 7.something of it. (I said vaguely....) Unfortunately whatever details I have about it are at home.
If you have version 8.whatever, then I don't know what the cause is, and therefore can't help fix it.
I really hate to suggest getting the latest version from Adobe, because, well, it's Adobe.
Hope somebody else has an answer for you.
BDF
A learned fool is more a fool than an ignorant fool.
-- Moliere
|
|
|
|
|
Ok, it's not an answer to your question, but it's just so good I have to recommend it: get Foxit Reader[^] and forget about Ad...what was that name?
|
|
|
|
|
Excellent suggestion, Luis. All the functionality without all the bloat.
BDF
A learned fool is more a fool than an ignorant fool.
-- Moliere
|
|
|
|
|
hi guys
In my application i need to read a file and substitute a particular occurrence of a word/keyword by corresponding word... to do this i am using a excel sheet with 2 columns. first column will be the keywords to be searched in the source file and second will be the corresponding keyword to be replaced... can some one pls provide me with the code for doing the same. the prog me be able to read the source file do modification and store the file in the same location..
thanks
sid
|
|
|
|
|
After you build your list of replacements, use Regex.Replace to alter the file and then write back out. Come back when you have some code that is troubling you.
To get you started you will need FileStream , Regex , and a custom class or KeyValuePair to store your list of replacements. There is plenty on google[^] on these topics.
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
rsiddhartht wrote: In my application i need to read a file and substitute a particular occurrence of a word/keyword by corresponding word... to do this i am using a excel sheet with 2 columns. first column will be the keywords to be searched in the source file and second will be the corresponding keyword to be replaced... can some one pls provide me with the code for doing the same. the prog me be able to read the source file do modification and store the file in the same location..
This is one inefficient Son Of a codeBloat. Why are you storing the matches in Excel? If only somebody had invented a technology where data could be stored and retrieved quickly and efficiently. Hey - there's a money making idea for you.
Anyway - once you've retrieved your data and read in the file you could always use a regex.replace or a string.replace.
|
|
|
|
|
Still learning C# and am using a structure as illustrated below to hold data.
To get the data out I cast the data into the relevant type.
My question is this - is this an okay way to store ones data or would using a dataset or other structure be faster or more efficient?
ArrayList - contains N members
Arraylist - contains 4 members
3 strings
1 Arraylist - contains N members
Arraylist - contains 3 members
1 string
1 byte
1 datetime
You always pass failure on the way to success.
|
|
|
|
|
Interesting... I would do it slightly different. Use the struct keyword to create a structure. Then place structures inside of your ArrayList. It will be easier to reference.
Hogan
<br />
private ArrayList groupOfItems = new ArrayList();<br />
<br />
private struct GroupStruct<br />
{<br />
public string string1;<br />
public string string2;<br />
public string string3;<br />
public ArrayList subGroup;<br />
}<br />
<br />
private struct SubStruct<br />
{<br />
public string subString1;<br />
public byte oneByte;<br />
public DateTime subTime;<br />
}<br />
|
|
|
|
|
Thanks - looks good, structures are new to me so I will give them a go.
From what I understand structs are kept on the stack so access is faster as well.
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: From what I understand structs are kept on the stack so access is faster as well.
a single struct would be, but if you're creating them inside an array list the memory they're stored in will be allocated by the arraylist which is on the heap.
You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always get punched out when I reach 4....
-- El Corazon
|
|
|
|
|
GuyThiebaut wrote: structures are new to me so I will give them a go.
Famous last words...
You should stick to using classes until you have read up on what structures are used for, and how to implement them.
GuyThiebaut wrote: From what I understand structs are kept on the stack
Only if you declare one as a local variable in a method. If you put one in an ArrayList, an object is allocated on the heap to put the structure in. This is called boxing, and isn't very good for performance.
Also, your data contains objects, and they will always be stored on the heap, so there is not really much point in putting it in structures.
GuyThiebaut wrote: so access is faster as well
The structures would be a bit big, so they would actually not be that fast to access. A structure should not be larger than 16 bytes, and your data would be pushing that recommended limit.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks - that's very helpful
In terms of size my data would definitely be pushing beyond the 16 byte limit.
Time to read up on structures.
You always pass failure on the way to success.
|
|
|
|
|
Puttings structs in an ArrayList? I'm just waiting for the next question from this guy:
"I have a struct in an ArrayList, but when I try to change the values in the struct, it doesn't work. The struct in the ArrayList just stays the same."
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If it does what you need...
|
|
|
|
|
PIEBALDconsult wrote: If it does what you need...
... you're done.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks - I'm always trying to learn how to write more, to make use of an overused word, beautiful code.
So easy maintainability, speed of access, resource hungriness(starting to sound like GW) and elegance of coding are important to me as I have written some awful code in my time and had to maintain the some pretty badly written code.
You always pass failure on the way to success.
|
|
|
|
|
Maybe you want to change your sig, and aim at success from the start, trusting you will NOT
always pass failure...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
As with Post-Its, some failures are successes in disguise.
I have (or had) a button that states:
"If at first you don't succeed, lower you standards."
|
|
|
|
|
PIEBALDconsult wrote: some failures are successes in disguise
Absolutely, keep an open mind and look for unexpected opportunities...
PIEBALDconsult wrote: If at first you don't succeed, lower you standards
Nope. If your aim is worthwhile then keep your standards high, and increase your perseverance,
I would say.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Unless you are stuck with framework 1.x, don't use the ArrayList class. It's obsolete.
Instead of storing different types of data in ArrayLists, make objects to store the data in, and make generic lists to store objects in.
List<C1> - contains N members
class C1 - contains:
3 strings
1 List<C2> - contains N members
class C2 - contains:
1 sting
1 byte
1 DateTime
This way you get rid of the boxing involved with storing value types in an ArrayList, the overhead of using ArrayLists only to store different kind of data, and you gain strict typing.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|