|
You may resize an image using DrawImage method of graphics object.
Following is a small code snippet showing this-
--------------------Code Start-------------------
Bitmap SourceImage= (System.Drawing.Bitmap ) Image.FromFile("C:\\img1.jpg");
Bitmap ScaledImage = new Bitmap(50, 50); //you may set size of scaled image here.
Graphics g = Graphics.FromImage(ScaledImage);
g.DrawImage(SourceImage, new Rectangle(0, 0, 50, 50), new Rectangle(0, 0, SourceImage.Width, SourceImage.Height), GraphicsUnit.Pixel);
ScaledImage.Save("C:\\scaledimg.jpg");
-------------------------Code End--------------------
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
The GetThumbnailImage method uses the embedded thumbnail if there is one, so you can only successfully use it to actually create thumbnails.
For larger miniatures, you have to do the work yourself:
Create a Bitmap object with the size you want, create a Graphics object to draw on the bitmap using the Graphics.FromImage method. Draw the image onto the bitmap using the DrawImage method.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
|
Hello All
I am trying to catch a right button down event for a control before the form sends it to this control; I tried to do that through overriding the WndProc
But it fails!
Is there any way to do that?
|
|
|
|
|
There is an option in the designer to have the form catch key presses before it sends them to a control, perhaps there is another for mouse events. I'd check myself, but i have to go.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
fellas
i am making a game of battleships and i have server and client talking sending and recieve etc
i can place all my battle ships and get the row and col, problem i cannot think on how to get the coorindates into an array in order to store and get them checked when a player sends a shot
here are the corrindates any help would be greatly appriceated
6-13,7-13,
11-10,12-10,13-10,
11-7,12-7,13-7,14-7,
6-5,7-5,8-5,9-5,10-5,11-5,
thanks
|
|
|
|
|
Just store the whole battle grid in an array. Use 0's for empty coordinates and use 1's to represent where a boat is placed. Then you can easily check the X,Y positions in the array for 0 or 1 to signify hit or miss.
|
|
|
|
|
I want to use pointers.bt the problem is c# does not provide pointers.
Is there any other method?
Regards,
chanzeb chaudhary....
|
|
|
|
|
C# does provide for pointers, but you need to compile with 'unsafe' code, so you need to set that option.
And then use the <font color="333333">unsafe</font> keyword, either for your class, or just like an if statement:
unsafe class myClass
{
}
class myClass
{
static void main(string[] args)
{
unsafe {
}
}
}
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
You can use pointers in C#. All you have to do is mark a method as unsafe (and change the assembly to allow unsafe code) and you are good to go.
|
|
|
|
|
Can we Serialize the static variables and generic lists ?
B V KIRAN KUMAR
|
|
|
|
|
Bhimuni wrote: Can we Serialize the static variables and generic lists ?
What have you tried? The best way to find something out like this is to write a piece of code that attempts to do just what you have asked. This way, you learn problem solving skills, rather than relying on somebody else to do your thinking for you - especially as they may well end up giving you incorrect information.
|
|
|
|
|
I have hosted a dhtml control on a C# form. I can not figure out a way to catch its text drag events.
|
|
|
|
|
I have an application that uses the System.Windows.Forms.WebBrowser control from .net 2.0.
I have noticed that the window does not resize when the window.ResizeTo javascript method is called.
However, when a AxSHDocVw.AxWebBrowser browser component is used instead, the same javascript works absolutely fine - resizing the browser control and the form containing it. I have a demo project that uses both types of controls on the same HTML page and for some reason the Windows.Forms.WebBrowser control just will not pick up the resize event.
This may be related - I've noticed that if you extend both controls, and override WndProc, the AxSHDocVw control will receive messages for WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED but the other control will not.
Does anyone know what the problem is or how to fix it? It is not possible for me to use the AxSHDocVw component instead.
|
|
|
|
|
Hello experts,
How can I manage global variables through out the application in C#.Net...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Use a static class. For instance:
public static class MyClass
{
public string MyKey = string.Empty;
} To refer to it in other places, you would use MyClass.MyKey = "Hello";
|
|
|
|
|
Create a public class named like Global
and make some public static property and access it in application anywhere
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Hello!
Ive been trying to make a regular expression remove everything from a string that´s not a numeric d1-10 with comma and d1-2 after. The expression looks like this:^\d{1,10}(\,)?(\d{1,2})?$, and I try to use it like this:
original = Regex.Replace(original, @"^\d{1,10}(\,)?(\d{1,2})?$", "");
but this amounts to nothing. If original for instance would be "345,46 £" I would want the £ and the blankspace removed. Does anyone know what Im doing wrong?
|
|
|
|
|
There are a couple problems with your code and regex.
First, the regex will match the correct pattern of 345,46, but only if it's at the beginning and end of the line (because you specify the ^ and $ before and after it). Because your input string has " £" at the end, your regex won't match.
Assuming that "345," is not a valid number, then the "(\,)?(\d{1,2})?" part should be "(,\d{1,2})?". If "345," is a valid number, then the "(\d{1,2})?" part should really be "\d{0,2}". I'm going to assume that "345," is not valid though.
Now, the actual parameters to the Replace method are incorrect also. Assuming you don't have any back references in the "replacement string", then whatever is match will be replaced. So you would be replacing the number, not the "extra" stuff.
Based on this your regex needs to be "^.*?(?<num>\d{1,10}(?:,\d{1,2})?.*?$", and your replacement string needs to be "${num}". This will extract the FIRST number to match the pattern. So in "123,4 dd 567,89", the resulting string will be "123,4".
Basically, we match the entire input string with our regex, but we save the number in the group named "num". Then we reference that group to generate the output.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
No problem. Please get the regex from my previous post again, though. I forgot to use & l t ; so the <num> part was removed.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi again!
I´ve tried your example but cant quite get it to work. In its original form I get an error message, "Not enough )'s". If I alter the regex to look like this
original = Regex.Replace(original, @"^.*?(?<num>\d{1,10}(?:,\d{1,2})?.*?$)", "${num}")
nothing happens with my string.
|
|
|
|
|
Sorry, the missing paren goes before the last .*?, so:
^.*?(?<num>\d{1,10}(?:,\d{1,2})?).*?$
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
|
Hi
Few question if any one knows answer plz let me know
1. What is MAC address ?
2. Is it unique to every system in a network
3. How to know the MAC Address of Clients System.
4. If Q2 answer is yes then how to find all the MAC address of the ' Systems connected in a network using C# code
Plz if any idea also share with me
REGARDS
Tiwari
its me sid
|
|
|
|
|