|
|
Thanks for your help Sibugathulla...... I will see try that, but for that I need to install VS.NET 2008.
Thanx again,
Rajdeep.NET
|
|
|
|
|
I have a function that takes the image in a picture box and converts it to a bitmap (System.Drawing.Image Picturebox.Image to System.Drawing.Bitmap) with the following code:
private void freezeFrame_MouseClick(object sender, MouseEventArgs e)
{
Bitmap refImage = new Bitmap(freezeFrame.Image);
int rangeLimit = 20;
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
int mouseX = int.Parse(txtMouseX.Text);
int mouseY = int.Parse(txtMouseY.Text);
Color currentPixel = (refImage.GetPixel(mouseX, mouseY));
curPixelRed.Text = currentPixel.R.ToString();
curPixelGreen.Text = currentPixel.G.ToString();
curPixelBlue.Text = currentPixel.B.ToString();
redMinUpDown.Value = currentPixel.R - rangeLimit;
redMaxUpDown.Value = currentPixel.R + rangeLimit;
greenMinUpDown.Value = currentPixel.G - rangeLimit;
greenMaxUpDown.Value = currentPixel.G + rangeLimit;
blueMinUpDown.Value = currentPixel.B - rangeLimit;
blueMaxUpDown.Value = currentPixel.B + rangeLimit;
}
I keep getting an invalid parameter error for the first line of the function. What am I doing wrong?
|
|
|
|
|
Please Update your first line as follows
Bitmap refImage = new Bitmap((Bitmap)freezeFrame.Image);
Or Convert Image to Bitmap and use this Bitmap as parameter.
©Something Different
|
|
|
|
|
How can I convert the image? Sorry for the noobish question...
|
|
|
|
|
Um.. with the code he gave you to do it ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
he said that I can do what he told me too or convert the picturebox image to a bitmap...i still get the invalid parameters error when i click on the image ....how do i do the picturebox image to bitmap conversion...i think there is something wrong with my code that is causeing the error
|
|
|
|
|
Hi,
several comments:
1.
sebogawa wrote: txtMouseX.Text = e.X.ToString();
int mouseX = int.Parse(txtMouseX.Text);
What a waste. You already have e.X as a number, why do you need to parse a string then. Just write
int mouseX = e.X;
txtMouseX.Text = mouseX.ToString();
2.
Bitmap refImage = new Bitmap(freezeFrame.Image);
You claim the problem is here, I doubt that. There are two ways this could fail:
a) freezeFrame.Image being null would result in a NullReferenceException
b) freezeFrame.Image being of some special ImageFormat (such as EMF) might cause problems, I'm not sure though.
3.
Color currentPixel = (refImage.GetPixel(mouseX, mouseY)); would throw an ArgumentOutOfRangeException when mouseX and/or mouseY fall outside the image.
4.
redMinUpDown.Value = currentPixel.R - rangeLimit; may cause problems since the lowest achievable value is negative (-rangeLimit). If Value is set outside [Minimum,Maximum] an ArgumentOutOfRangeException will be thrown.
Overall, your code is low-quality as it lacks a lot of checks.
|
|
|
|
|
|
If you want 4 bits, you could store two values in each byte ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
did you read my Question well,I doubt
what this means:
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
!!!!!!
Mohammed Ibrahim
|
|
|
|
|
Mohamed Ibrahim Omar wrote: what this means:
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
!!!!!!
Do you mean that you don't understand what it actually means or don't understand that it's his signiture?
Either way it's the funniest thing I've read all day!
My failometer is detecting vast quantities of FAIL!
|
|
|
|
|
Mohamed Ibrahim Omar wrote: what this means:
It means that you are not very good at English. Perhaps this is why your questions are confusing, and you don't get the answers you want.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
you always (Christian Graus)give me bad answer
Mohammed Ibrahim
modified on Saturday, April 25, 2009 6:17 PM
|
|
|
|
|
Your question is kind of stupid. You want to make a byte equal to four bits ? You can't. There's no type that is four bits.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Mohamed Ibrahim Omar wrote: byte[]
And you wonder why it's a byte?
Not sure if this will help or not but have a look at BitArray[^]
My failometer is detecting vast quantities of FAIL!
|
|
|
|
|
Seriously, everyone here wants to help you, you should try to make your question more clear, not delete it. I wasn't being insulting, if English is not your first language, that's not meant as an insult, but, if we can't understand what you mean, we can't help, that's all I was trying to say. Provide more detail and perhaps when we can better understand your need, we can offer better help ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I have an array that I am converting values from. It is a comma delimited file, and has some null values in it. While I am reading the file to convert, how can I handle the null values?
|
|
|
|
|
with code ? I don't see what the question is. If you are writing code to convert values, can't you check for null first ? It's up to you if you skip a null, or insert a default value in it's place.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I apologize if my question seemed stupid. I am looking for assistance with the code, which is why I am in the C# message board.
|
|
|
|
|
If you posted some code, then perhaps we could assist you with your code. As it stands, we're struggling to understand what the hell you're talking about. If you have null values coming in ( we don't even know where from ), then you can check for them, surely ? Perhaps not, in your situation, but you've not come close to making that clear.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
impossible to answer: you hardly described the input and didn't say a thing about the output.
explain more, AND give some examples.
|
|
|
|
|
Please Don't Worry You can Solve NullException problem Using one of the two methods .
1) If you create Your own Array Please Initalize it.
List<String> strArray= new List<String>();
strArray.Add("Code Project");
Here new List<String>(); is important
2) If you get the list from any where else You can check for null as follows
if(strArray != null)
if(strArray.Count >0)
MessageBox.Show(strArray[0]);
|
|
|
|
|
Hi there,
I'm trying to read .xls file using OleDb connection. I have two .xls files generated from SAP (actually these are Unicode text files saved as .xls) with two different names. When I execute my code I can only open one file, the second one gives an error:
System.Data.OleDb.OleDbException: The Microsoft Jet database engine could not find the object 'sheetName$'. Make sure the object exists and that you spell its name and the path name correctly.
Both files contains only one sheet which has the same name as the file itself. I've checked the spelling several times and even changed it manually but it doesn't work on one file. Even when I saved the file as proper Excel file. Here's the code I'm using:
string fileNameWithExt;
string fileNameWithoutExt;
int fileNameLength = 0;
int cutExtension = 4;
fileNameWithExt = openFileDialog1.SafeFileName;
fileNameLength = fileNameWithExt.Length;
fileNameWithoutExt = fileNameWithExt.Remove(fileNameLength - cutExtension);
OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\" + fileNameWithExt + ";Extended Properties=Excel 8.0");
aConnection.Open();
DataTable sampleDataTable = new DataTable();
dataGridView1.DataSource = null;
sampleDataTable.Clear();
sampleDataTable.Columns.Clear();
OleDbDataAdapter oleDbCommand = new OleDbDataAdapter("Select * from ["+fileNameWithoutExt+"$]", aConnection);
oleDbCommand.Fill(sampleDataTable);
I hope somebody can point me in the right direction as I checked plenty of posts and know that something is wrong with the sheet name but can find the issue.
Regards,
|
|
|
|
|
some questions:
1. are you having both xls files open at the same time?
2. are you closing aConnection when done with each file?
3. what is the full and exact content of fileNameWithExt in both cases?
4. in exactly which line does the exception occur?
|
|
|
|