|
Search the articles for "Image processing for dummies" and you'll find a series of articles that covers just what you're looking for.
|
|
|
|
|
Hi,
1.
an easy win is to replace pic.Height by a variable that gets initialized only once.
2.
for a fixed color, there are better ways, as Henry already mentioned. Here is one:
Graphics g=Graphics.FromImage(newpic);
g.FillRectangle(...);
g.Dispose();
3. the general solution for maximum performance is using pointers, avoiding GetPixel/SetPixel since these methods will perform boundary checks and coordinate conversions for each individual pixel.
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 have realised that I made a typo, had a brain fart, in my previous post.
I should have said
If it is going to be one color investigate the Graphics class and the Clear method of that class. Although the various Fill methods are good to know.
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.”
|
|
|
|
|
Thank you all for your good answers.
|
|
|
|
|
Hi,
Pop3 and Smtp work the sameway.. one sends a string message to the server (eg: HELO, USER user, PASS pass) and the server responses (eg. 250 Hello and welcome)
Is there any standard class for this type of communication? something simple like
+Connect()
+Write(s)
+LastResponse()
Because i'm not getting good results ..though i'm trying to communicate with gmail's pop and smtp, so maybe i'm failing with the SSL thing..
I'm having trouble with the Writing and Response,
public string SendMessage(string message)
{
ASCIIEncoding asciiEncoder = new ASCIIEncoding();
byte[] WriteBuffer = new byte[1024]; // 1 KB
WriteBuffer = asciiEncoder.GetBytes(message);
NetworkStream stream = cl.GetStream(); // cl is a TcpClient
stream.Write(WriteBuffer, 0, WriteBuffer.Length);
// Get response after message
return Response();
}
And my response method is:
public string Response()
{
byte[] serverbuffer = new Byte[1024]; //1 KB
int count = ns.Read(serverbuffer, 0, 1024);
if (count == 0)
{
return "";
}
return Encoding.ASCII.GetString(serverbuffer, 0, count);
}
|
|
|
|
|
Hi All,
My break points doesnt not work.I break on a certain part of my code and when i run the code it doesnt stop at the break point.
Could you please advice?
Thank you in Advance.
Many thanks
|
|
|
|
|
This often means that a piece of code that you expected to be called isn't, for some reason. Usually, because of an error in coding, or it is with me.
What I do is to place a break point in the calling code for your original break, and keep moving up the calling chain until something bites.
When that happens, step through until you discover the error.
If that doesn't work, I go for a cup of coffee and a lie down.
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.”
|
|
|
|
|
If that doesn't work, I go for a cup of coffee and a lie down Hahahahahah.....
Thanks very much Henry.Its Much appreciated.The problem with my debugging is even i start a new project that doesnt have any code in it and i place a break point it doesnt stop at it.Any idea?
Thank you.
|
|
|
|
|
If your new project doesn't have any code, how do you set a breakpoint?
You can only set a breakpoint on a line of reachable code, without getting a warning.
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.”
|
|
|
|
|
Thank you once again.I just declared a variable and assign a value to it.
|
|
|
|
|
This may sound realy stupid, but are you actually debugging?
If you create a new (for example) console project, and enter a single line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
int i = 1;
}
}
}
Then click to the left of the line to create a breakpoint, does a red dot appear?
When you run it, how are you doing that? Try running it from the menu "Debug...Start debugging"
What happens when you start the program using "Debug...Step into"?
I apologise if this seems a little too simple and basic, but sometimes it is worth starting at the begining.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
i have a class name DataConnection. and i want to call this in my form. so how to do with C# ? please give me some guide line ....
|
|
|
|
|
Well it all depends how you have them set up.
Are your classes both in the same namespace? If so, then you can access the Class directly.
Do you want to create an instance of the class? or have you already done that and what to access one of its functions?
If you want to create an instance you can use
DataConnection dc= new DataConnection();
then call a function...
dc.FunctionCall();
from inside your form. Unless it is a static class in which case you cannot create an instance of it, but you can call any of its public methods like so...
DataConnection.FunctionCall();
Any help?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
yes. please tell me more detail ... i have a project name Stock. and it has a form name "form", and a class name DataConnection. in DataConnection has only property "S" as string. and why i cannot access to "S" directly by "string str = DataConnection.S" ? why need to create an instand of it first ?
|
|
|
|
|
You need to create an instance first because, until you do, nothing will exist. You need to make sure that S is declared public as well.
Alternatively, you can declare S as public static , in which case you can use it as you currently do.
In any event get yourself a beginners C# book and work through it. You will save yourself a lot of pain.
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.”
|
|
|
|
|
is C# has readonly keyworld ? and how it use in declare a property in Class ?
|
|
|
|
|
xingselex wrote: is C# has readonly keyworld ? and how it use in declare a property in Class
1. Yes.
2. public/protected/private (delete as applicable) readonly string S = string.Empty;
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.”
|
|
|
|
|
ok thank Henry Minute
|
|
|
|
|
my code is like this bellow . and why it message that "the modifier 'readonly' is not valid for this item " . what wrong with it ? sorry for my question. i'm just start to learn about coding...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace Stock
{
class DataConnection
{
private string _ConnectStr = "";
public readonly string ConnectStr
{
get
{
return _ConnectStr;
}
set
{
_ConnectStr = value;
}
}
public DataConnection()
{
string str = "Data Source=sokheng;Initial Catalog=stock;User Id=sa;Password=";
try
{
System .Data .SqlClient .SqlConnection CN = new System.Data.SqlClient.SqlConnection() ;
CN.ConnectionString = str;
CN.Open ();
_ConnectStr = str;
CN.Close ();
}
catch(Exception ex)
{
}
}
}
}
|
|
|
|
|
You mixed "readonly" with a property, you could do this:
public string ConnectStr
{
get
{
return _ConnectStr;
}
private set
{
_ConnectStr = value;
}
}
|
|
|
|
|
why i cannot use "MessageBox.show" in my class ? i want to show when catch an error ...
|
|
|
|
|
Your name is Rajdeep.NET and I claim my £5!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
If it's a property you don't even need the readonly keyword, you could make the getter public and the setter private (or protected)
|
|
|
|
|
As Henry has said, you can access it the way you are trying only if the S string is static and publicly available. Which I am guessing is not the case.
ensure you DataConnection class is similar to the following...
public class DataConnection
{
private string s = "default";
public string S{
{
get{return s;}
set{s = value;}
}
}
then in your main form you need to create an instance of your DataConnection class in which you can access the value of S, like so...
DataConnection dc = new DataConnection();
dc.S = "new value";
MessageBox.Show(dc.S);
you need to ensure that your DataConnection instance is located in an appropriate place depending on where you want to access the data from i.e. mulitply functions would mean you should set it at a class level
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi guys. I got a problem I cant find solution to anywhere over the internet..I might have missed something in my logic.
<pre>
class DefComparing:DefCompareProperty
{
public void DefCompare()
{
List<string> def_compare = new List<string>();
********doing something to the list here******
DefCompareProperty df = new DefCompareProperty();
foreach (string s in def_compare)
{
df.SetDefComp(s);
}
}
}
</pre>
Then I want to use the def_compare list in another class.
<pre>
public class Aliniere
{
public List<string> def_compare = new List<string>();
public void Aliniate()
{
******doing some operations here****
DefComparing newdefcomp = new DefComparing();
newdefcomp.DefCompare();
def_compare = df.GetDefComp(); //Trying to get the list from that other class
</pre>
What I tried to do is make Set/Get properties for the list.
<pre>
class DefCompareProperty
{
private List<string> lst = new List<string>();
public List<string> GetDefComp()
{
return lst;
}
public void SetDefComp(string members)
{
lst.Add(members);
}
}
</pre>
So the problem is I cant get the list from class1 to class 2 using class3(set/get). I am doing some mistake. Can you help?
Thanks in advance
|
|
|
|