|
Create a new Bitmap object with the size you want, use the Graphics.FromImage method to get a graphics object for the image, and use that to draw the original image onto the new image at the correct size.
---
single minded; short sighted; long gone;
|
|
|
|
|
thanks allot for reply
but a code example will be better.
thanks
|
|
|
|
|
using (Bitmap bitmap = new Bitmap(200, 200, PixelFormats.Format24bppRgb))
{
using (Graphics gfx = Graphics.FromImage(bitmap))
{
gfx.DrawImage(originalImage, 0, 0, 200, 200);
}
bitmap.Save(@"filename.bmp", ImageFormats.Bmp);
} Or something like that.
|
|
|
|
|
thanks allot
i will try it
it converts from a higher resolution to a lower one, is not it?
|
|
|
|
|
That depends on what you mean by resolution.
It converts an image of any size to the specificed size, regardless if the original image is larger or smaller.
---
single minded; short sighted; long gone;
|
|
|
|
|
thanks allot
it really did the job.
|
|
|
|
|
I have control Lable on Form , I wanted to update text propertrty of that control from another class in same namepsace so I expose that label control visa public property . and now I m using that property in my other class for setting text fro that lable .. but the new text is not displaying on Form ???
What I am doing wrong here ???
Class Form1 {
public string updatelable
{
get
{
return label.text ;
}
set
{
label.Text = (string)value;
}
and using it in my other class as
Form1 f = new Form1();
f.updatelable = "abc";
but its not working... what I m doing wrong here ???
Thanks
HELLO
|
|
|
|
|
Hello,
You have to add "this.Refresh()" in the set of your property.
All the best,
Martin
|
|
|
|
|
You can only update the control in the UI thread. You'll need to use invoke, or some other method to update the text on the label.
only two letters away from being an asset
|
|
|
|
|
I am using Asynchronous methods in my extern class and trying to update UI from these methods .
I have created a delegate and delegate method in Form1 class and when I tried to invoke delegate from external class it says definition of invoke does't exist in current reference ... ???
What I m doing wrong here ?
Thanks
|
|
|
|
|
Hello,
For helping you we hav to know a little more.
Please show us the code of:
delegate, invoke call and method;
|
|
|
|
|
Hi all,
i've created a user control, and using too
but now --My requirement is i need to use the same control in the same form many times,
plz help me with solution...
i am trying by taking an array..[but i couldn't proceed]..plz help me asap.
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Hello,
I don't know why you need an array?
Or do you whant to hold the reference of you controls in your forms class?
int many = 10;
System.Collections.Hashtable AllControls = new Hashtable();
for(int x=0;x<=many;x++)
{
UserControl2 myControl = new UserControl2();
myControl.Location = new Point(10, x*(myControl.Height+10));
this.Controls.Add(myControl);
AllControls.Add(x, myControl);
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
I'm new to C# threads and I was trying to populate a list with a series of threads but my list is not being populated after the threads finish. Some code might help describe my situation:
NOTE: I have left some methods out but I don't believe that will be an issue.
public class ManagerClass {
private List<BeanType> beans = new List<BeanType>();
private static Object lockObj = new Object();
private static readonly int MAX_THREADS = 5;
public List<BeanType> getBeans() {
string[] keys = null;
keys = getKeys();
ThreadPool.SetMaxThreads(MAX_THREADS, MAX_THREADS);
foreach (string key in keys) {
ThreadPool.QueueUserWorkItem(new WaitCallback(getValueThreaded), key);
}
Thread.Sleep(10000);
Console.WriteLine(beans.Capacity);
return beans;
}
public void getValueThreaded(object obj) {
string key = (string)obj;
string value = getValue(key);
lock(lockObj) {
beans.Add(new BeanType(key, value));
}
}
}
That is the jist of it. BeanType is an arbitrary type for the sake of this example.
In the console the list prints out a capacity of 0 every time. Can anyone explain this?
-- modified at 11:20 Tuesday 6th March, 2007
-- modified at 12:24 Tuesday 6th March, 2007
Kelsen
|
|
|
|
|
foreach (string key in keys) {
ThreadPool.QueueUserWorkItem(new WaitCallback(getValueThreaded), key);
}
Console.WriteLine(beans.Capacity);
Kelsen wrote: In the console the list prints out a capacity of 0 every time. Can anyone explain this?
Could it be that the console prints out before the thread pool items have a chance to run?
|
|
|
|
|
Leslie Sanford wrote:
Could it be that the console prints out before the thread pool items have a chance to run?
I migrated the WriteLine outside of the method and it still outputs 0. The code looks like:
public class SomeClass {
private static ManagerClass manager = new ManagerClass();
public static void Main() {
List<BeanType> beans = manager.getBeans();
Console.WriteLine(beans.Capacity);
}
}
I also placed a wait at the end of the getBeans method. Any ideas?
Kelsen
|
|
|
|
|
Kelsen wrote: but my list is not being populated after the threads finish.
Kelsen wrote: Can anyone explain this?
The threads are NOT "finished" after they are "queued", they are ummmm... queued.
led mike
|
|
|
|
|
led mike wrote: The threads are NOT "finished" after they are "queued", they are ummmm... queued.
After the foreach completes and finishes waiting the threads should have finished executing. An example I wrote prior to posting this question was:
public class ThreadTest
{
private static readonly int MAX_THREADS = 5;
public static void Main()
{
ThreadPool.SetMaxThreads(MAX_THREADS, MAX_THREADS);
for (int i = 0; i < 20; i++)
ThreadPool.QueueUserWorkItem(new WaitCallback(processThread), (i + 1));
Thread.Sleep(25000);
Console.WriteLine("Finished!");
}
static void processThread(object obj)
{
Console.WriteLine("Thread " + (int)obj + " executing.");
Thread.Sleep(5000);
}
}
This is of course assuming the Thread.Sleep(25000) will be long enough for the last 5 threads to execute. In my original post I didn't show my Thread.Sleep() but it was there within my code. I'll better document that to help clear up any confusion.
Kelsen
|
|
|
|
|
led mike wrote: The threads are NOT "finished" after they are "queued", they are ummmm... queued.
Yup. Figured it out.
Kelsen
|
|
|
|
|
Hi, I need to make an area, kind of like the Windows Desktop, that is, in which I can move large icons around.
I thought I could do it with PictureBoxes but they lack the editable name, which I would rather have. Then I thought I could do it with a LargeIcon listview, but there doesn't seem to be any way of moving the items around (which is kind of logical since it's a "list".
Anyway I was wondering if there was any way to do this, and if there isn't what control could I use? Would I really have to mimick a LargeIcon in a UserControl?
Thank you very much!
|
|
|
|
|
goldoche wrote: but there doesn't seem to be any way of moving the items around
You mean like "sorting" the list?
led mike
|
|
|
|
|
No I mean dragging items around, placing them wherever I want. Like we do with the icons on the Windows Desktop.
|
|
|
|
|
So this [^] did not work?
led mike
|
|
|
|
|
No it didn't. The AutoArrange is set to false and I've tried every Alignment option and I'm unable to drag them!
|
|
|
|
|
I make a class MyClass with Nmae and Age like properties
I make an object myClass like that.
I make a form with a propertygrid and added the myClass object to the propertygrid.
I put a textbox for Name and a textbox for Age. a button when is pressed change the values of the myClass with the values from the two textboxes, but in propertyGrid I see the old value.
I put [RefreshPropertiesAttribute(RefreshProperties.All)], and Repaint, and [RefreshProperties(RefreshProperties.All)], and Repaint, but doesn't work.
Have u any idea?
10x
|
|
|
|