|
Hi,
there are some quirks you have to be aware of:
1. all errors in GDI+ will report "an internal error..."
2. Image.FromFile() locks the file until the image is disposed
BTW: Image.FromStream() does not
Bitmap bm1 = Bitmap.FromFile(filename);
Bitmap bm2 = new Bitmap(width2, height2);
Graphics g = Graphics.FromImage(bm2);
g.Transform = matrix...;
g.DrawImage(bm1);
bm1.Dispose();
bm2.Save(filename, imageFormat);
g.Dispose();
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Oh I swear, thank you SOOOO much. I couldn't figure out which object I wasn't dispoing of properly. I knew there was something wrong because if I could create a new bitmap as a new file name it would work, as it wasn't trying to write to the same STILL open file!!
Now on to figuring out to get it to rotate properly given the angle...ehhh.
Thanks for the help everyone!!
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I'm writing an app to add information to a custom database(which does not exist yet). After that, I will develop an app to work with/view the data.
As a newbie, I'm unaware of exactly what I should be studying to create a database in C#. I've figure out how to create data tables(and datasets) but I'm not sure what to even search for when I'm trying to find code samples or tutorials on how to permanently store the info and every search I do yields stuff with MySQL. Can someone please point me in the right direction?
|
|
|
|
|
You need to learn about SQL. That's basically it. That's what DBs are written in
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 )
|
|
|
|
|
well there are plenty articles here at CP. Take alook[^]
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Dear developers,
I like the type of chm-file for documentation.
I fiddled a while with the ms-help and I understand some principles.
My question is:
How can I automate the creation of "pretty-looking" chm-files?
Best regards
|
|
|
|
|
|
We've had a very good experience with HelpScribble:
http://www.helpscribble.com
David Anton
http://www.tangiblesoftwaresolutions.com
Convert VB to C#, C++, or Java
Convert C# to VB, C++, or Java
Convert C++ to C#, VB, or Java
Convert Java to C#, C++, or VB
|
|
|
|
|
Hi, I built an application using a TCP/IP connection. Therefore I need an I.P. checker to make sure the given IP is correct. I noticed that when an invalid IP is provided the complier can tell it right away. SO my quesion is if there is a command to check if an IP address is valid. By valid I mean it is less than 255.255.255.255. Or if you happen to have a code that does it i would be greatful.
Thank you in advance
|
|
|
|
|
Hi,
I haven't tried it myself but I would go for IPAddress.TryParse()
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
You could either ping it (requires internet access), use a regular expression, invoke the IPAddress.TryParse method or split it, and use Byte.TryParse on each of the components
|
|
|
|
|
Thanks, used IPAddress.TryParse() worked fine for me.
|
|
|
|
|
Hi all!
I was just wondering how I could elevate privelages programmatically using C# as I am trying to download a file from my site and automatically save it to My Documents on my computer but I keep getting an exception and it says access to MyDocuments denied. Does anybody know how to get around this? It happens on both my XP and Vista computers. I don't want to turn off UAC or the equivelant in XP either? I'd appreciate any advice I can get. Thanks in advance.
Jay.
P.S. Incase anybody wants to know how to download files using WebClient, here's the code:
WebClient DownloadClient = new WebClient();
DownloadClient.DownloadFile(StartingPointTextBox.Text, SaveSessionTextBox.Text);
j.t.
|
|
|
|
|
Hi,
you don't need special privileges to write files into your own MyDocuments folder, this works just fine (tested on Vista):
string ff=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+@"\folder\";
Directory.CreateDirectory(ff);
File.WriteAllText(ff+"aha.txt", "contents");
Did you get an error in the path, resulting in a non-existing folder/subfolder?
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thanks for your reply/code ,
Here's the code that I have. I haven't forgotten any folders (I double checked after reading your message) and I'm completely baffled. I even try saving the file to the Desktop and about 15 other folders lol but it shows the same access denied error on both systems. Weird. I've never had this happen before.
Below, the StartingPointTextBox is where the file's downloaded from, and the SaveSessionTextBox is where it'll be saved to:
DownloadClient.DownloadFile(StartingPointTextBox.Text, SaveSessionTextBox.Text);
In my application, I have a FolderBrowserDialog appear that lets me choose where to save the downloaded file to.
Jay.
j.t.
|
|
|
|
|
Hi Jay,
the code you are showing doesn't tell me anything, since the file path is to be read from a Control.
AFAIK a FolderBrowserDialog returns the path to an existing folder, which is *not* the path of a file inside that folder. You can't overwrite a folder with a file. Try appending some relative file path (such as "aha.txt") and then save.
FWIW: when something fails, make it log its intermediate values; as in Console.WriteLine("filespec="+f);
That often is the fast way to spot what may be wrong.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Luc Pattyn,
Thank you so much for your help and code I really appreciate it.
Unfortunatly, I'm a little brain dead tonight as I just figured out that I was telling it to save to a folder, but I wasn't giving it a filename to save as lol.
Regards,
Jay.
j.t.
|
|
|
|
|
Does a C# hashtable key have to be a string or could it be an int?
Cheers, Bruce
|
|
|
|
|
Hi Bruce,
a Hashtable, and since 2.0 also a generic Dictionary, does not impose limitations on the type of keys and values it takes. The key can be a string, an int, a MenuItem, whatever. It must have a decent hashing function, as documented for Dictionary< TKey, TValue>:
As long as an object is used as a key in the Dictionary< (Of < (TKey, TValue> )> ), it must not change in any way that affects its hash value. Every key in a Dictionary< (Of < (TKey, TValue> )> ) must be unique according to the dictionary's equality comparer. A key cannot be nullNothingnullptra null reference (Nothing in Visual Basic), but a value can be, if the value type TValue is a reference type.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
|
So if I make it an int for example do I have to overide any hashing functions? In my ap the key would be a uint32 and the value an int.
Cheers, Bruce
|
|
|
|
|
Bruce Coward wrote: So if I make it an int for example do I have to overide any hashing functions?
No, you don't have to. You could also consider using a generic dictionary instead of HashTable.
|
|
|
|
|
how can i get IO read/write bytes for each running process
(like IO columns in windows task manager) using API in c#?
|
|
|
|
|
Hi,
the PerformanceCounter class wraps Windows performance counters, which can provide that kind of information.
BTW: most often you need to call a counter twice, once to get it started, once again to read its value after some time has elapsed.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|