|
hi
i want to read bmp image and then save that by RLE(run length encoding) algorithm and return rle file to bmp file.
this is my first project about image. i am inexperienced.
please tell me your recommands for do this project.
|
|
|
|
|
First look here: http://en.wikipedia.org/wiki/Run-length_encoding[^]
But then observe that it will only work well for pictures with many pixels of the same colour in a row.
A better idea (not very advanced, but a nice hobby project perhaps) would be to estimate the colour of every pixel based on only preceding pixels (often predicted as a weighted average of the pixel left, above, left-above and right-above) and then calculate the difference between the expected colour and the actual colour. Then apply RLE to that (now it will also compress gradients) and then Huffman encode it.
It wouldn't really work on photo's, but it's ok for screenshots and diagrams.
edit: note that applying Huffman coding means that you can use a new symbol for the RLE marker thing, instead of having to do crazy hacks with "escape sequences" and such. For extra winnage you can put the length symbols in a different alphabet and Huffman compress them separately (or just output them as raw bytes) - best not encode them in the same way as the actual data since that would mess up the symbol frequencies.
|
|
|
|
|
|
I have used LINQ in the past to call stored procedures, but this is my first time using LINQ to SQL instead of ADO.Net and stored procedures.
So far I really like it. My only issue with it is that if a table changes you have to delete the table from the model and re-add the table. Is there no way to have the dbml class scan the database for changes?
Also, the System.Xml.Linq classes are incredible. I have to process a bunch of XML in this application and I can't believe how easy it is.
I didn't get any requirements for the signature
|
|
|
|
|
I just use ADO.net; it's simple, I'm in control, I don't have to worry about what it's doing in the background.
|
|
|
|
|
Same as PIEBALDconsult, at the moment. I'm looking into the other two options at the moment (very early stages).
You are absolutely correct about LINQ to XML though. IMNSHO it is the best of the XML access technologies in .NET.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
I have a windows form that can be moved around by clicking and dragging on any portion of the form. I used the method of overriding WndProc, and setting the result of the NCHITTEST function to be HTCAPTION, in order to fool the form into thinking I clicked the caption - so it enables dragging.
The code for this works great, and is below:
protected override void WndProc(ref Message msg)<br />
{<br />
if (msg.Msg == (int)WinAPI.NCHITTEST)<br />
{<br />
DefWndProc(ref msg);<br />
if ((int)msg.Result == (int)MousePositionCodes.HTCLIENT)<br />
{<br />
msg.Result = (IntPtr)MousePositionCodes.HTCAPTION;<br />
return;<br />
}<br />
}<br />
}<br />
base.WndProc(ref msg);<br />
}
The problem occurs when I dock a ToolStripPanel into the form (this is acting as a draggable toolbar). I need any portion of the ToolStripPanel that is not covered by a ToolStrip to pass up the messages necessary to cause the whole form to enter drag mode.
I have created my own ToolStripContainer class to override the WndProc function and have tried using the same function as above, but it causes the ToolStripContainer to enter drag mode *within* the form, which is not the desired functionality.
I have also tried passing up NCHITTEST messages to the parent, as well as constructing a new message with the current mouse coordinates and sending it to the parent using the WinAPI and the parent's window handle.
I have to be missing something simple here... Anyone have any ideas?
|
|
|
|
|
Hello,
I use SortedList as follows:
sortedlist sr=new sortedlist();
sr.add("abc","def");
How can i retrieve the value according the key? I mean if the key is "abc" and the value is "def"?
I mean when i write sr.getkey it can receive only integer , i mean sr.getkey(int) but i need string as key.
Also when i use :
sortedlist<string,string> sr=net sortedlist();
sr.add("abc","def");
and i do :
string k=sr["abc"];
it says : The given key was not present in the dictionary
Also i tried SortedDictionary but it's the same with it
|
|
|
|
|
Try the Generic Version, it seems to work fine for me with similar code to yours.
|
|
|
|
|
What does it mean Generic Version?
|
|
|
|
|
use System.Collections.Generics.SortedList instead of System.Collections.SortedList. If you are using 2005, Visual Studio defaults to the wrong namespace when creating your class files for you.
|
|
|
|
|
SortedList<string, string> sr = new SortedList<string, string>();
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
your code does not compile at all. There isn't a single line without errors.
If you fix all the typos you would get one compile-time error (cannot implicitly convert...).
So you have to add an explicit string casting (or replace the old SortedList by a generic one).
If you want to ever become a successful programmer you need to become meticulous right away.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I used the system.collection.generic but it doesn't help as well.
|
|
|
|
|
Visual Studio 2005 is fine for .NET 2.0 (the first version offering generics).
You have another typo. Read the documentation and follow it to the letter.
[EDIT] In the previous version of your reply, the one containing:
Ok thanks,
But there is a problem- I use VS2005.
I wrote :
using System.Collections.Generics;
(i wrote using system.collection too).
But I get error saying that the type or namespace Generics does not exist in namespace system.collection
you had another typo.
[/EDIT]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Does this code even compiles?
Following works perfectly fine for me:
SortedList<string,string> sr=new SortedList<string,string>();
sr.Add("abc","def");
string k=sr["abc"];
To be on the safer side, you can use TryGetValue method.
जय हिंद
|
|
|
|
|
Here is a snippet from my code:
SortedList <string, string=""> focus_URLS = new SortedList <string, string="">();
focus_URLS.Add("AR Coater","ARC+Lab&MachineName=AR+Coater&TypeID=2&StationID=1&datatype=0");
string focus_url_end = focus_URLS["AR Coater"];
but i receive error saying the key wasn't found
|
|
|
|
|
Does anyone know the problem?
|
|
|
|
|
Earlier today I had this exact error.
In my case it was because the key had been added with a preceding space. i.e. key = " abc", search = dict["abc"] <== error
So ensure that there are are no extraneous spaces in either the key, when added to the list, or your literal in the lookup.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
OH LOL it seems that it's working now.
I so hate this kind of error- you can do everything and you won't fix it because you don't think of such things
|
|
|
|
|
Hi,
Can someone please help me.
I am getting error: The process cannot access the file 'c:\reports\PaymentDetailReport.xml' because it is being used by another process. in following function.
This method is suppose to be called couple of times. but at second time, it throws the error. I have even closed tw.
private void saveReport(string reportName, string data)
{
if (reportName == "PaymentReport")
{
StreamWriter tw = new StreamWriter(_documentName);
tw.WriteLine(data, true);
StreamWriter masterPSDR = File.AppendText("C:\\reports\\masterPSDR.xml");
masterPSDR.WriteLine(data, true);
tw.Close();
masterPSDR.Close();
}
|
|
|
|
|
You may need to call Flush()[^] on yur StreamWriters.
Put them both in using blocks too
using(StreamWriter tw = new StreamWriter(_documentName))
{
}
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi,
sonya_rbi wrote: I have even closed tw
You're too kind. Of course, if you create or open something, you have to close it too.
My bet is you are victim to the goodness of Windows or one of the utilities you added. Here is a standard text snippet explaining the risk you are under:
---------------
if you want write or delete access (anything other than read access) to a file that just got created (by yourself or someone else, does not matter), chances are you will find the file is being accessed by some other process, and your access is not granted.
The other process very likely is some server code that is there to assist you somehow. Candidates are:
- anti-virus software (Norton, McAfee, whatever)
- indexing software (Google Desktop, MS Office, whatever)
The common thing is these packages are looking all the time for new files, so they can inspect them.
Microsoft is aware of the consequences; Windows Explorer will try rename and delete attempts up to five times (with one-second interval), and only reports failure if the action continues to fail for that time.
The solution:
1. either use a different file name
2. or remove all background reader candidates (bad idea)
3. or implement the retry loop as Explorer has it (use a Windows.Forms.Timer
for this)
BTW: if all you need is Read, make sure to allow others to read as well, i.e.
use File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)
---------------
In my experience, this happens when the succesive open/write/close cycles are more than 1 second apart; if you do it more frequently, you won't have any trouble (I log stuff with open/write/close all the time).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Everyone,
I have been trying to figure out an elegant way to get the result I want to something that must be a very common issue; getting the user to choose the COM port from a list. I can't find a neat solution out there, I thought maybe someone here would have a suggestion.
The setup is a new WPF window is spawned that just contains a ComboBox (for now) for choosing the COM port, this needs to be double bound. The first binding is to get the array of strings from the SerialPort.GetPortNames() static method, these will be the items in the list.
portList = new System.Collections.ArrayList(16);
foreach (string port in System.IO.Ports.SerialPort.GetPortNames())
{
portList.Add(port);
}
comPortListBox.ItemsSource = portList;
The next binding is to SelectedItem which should get and set the value in the properties of the application. When the window is closed, the properties are saved.
Properties.Settings.Default.SerialInterfaceComPort
Properties.Settings.Default.Save();
I have included how I am currently making it work below, there is a lot of code tho and it has some bugs to do with the properties value returning null sometimes.
I should point out that in the example the baud rate list works perfectly as it is based on a list of values in the XAML and I don't have to create it from a string array. Although, if anyone knows how to get a list of valid port speeds for a particular port that could be made pretty fancy.
Any suggestions on how to make this nice and elegant with better data binding would be great!
Thanks
Ed
public SerialSettingsWindow()
{
InitializeComponent();
portList = new System.Collections.ArrayList(16);
foreach (string port in System.IO.Ports.SerialPort.GetPortNames())
{
portList.Add(port);
}
tempComPort = Properties.Settings.Default.SerialInterfaceComPort;
tempBaudRate = Properties.Settings.Default.SerialInterfaceBaudRate;
comPortListBox.ItemsSource = portList;
int portIndex = portList.BinarySearch(Properties.Settings.Default.SerialInterfaceComPort);
if (portIndex >= 0 && portIndex < comPortListBox.Items.Count)
{
comPortListBox.SelectedIndex = portIndex;
}
else
{
comPortListBox.SelectedIndex = -1;
}
baudRateListBox.DataContext = Properties.Settings.Default;
}
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.SerialInterfaceComPort = tempComPort;
Properties.Settings.Default.SerialInterfaceBaudRate = tempBaudRate;
Properties.Settings.Default.Save();
this.Close();
}
private void doneButton_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.SerialInterfaceComPort = comPortListBox.SelectionBoxItem.ToString();
Properties.Settings.Default.Save();
this.Close();
}
}
|
|
|
|