tags:

views:

244

answers:

4

Don't ask me why but i can't use this method because I need to create 2 image objects to make it work.

I want to be able to resize a single Image object without needing to create another one. Is this possible and how?

A: 

You can put Image into a ViewBox.

See http://www.wpftutorial.net/ViewBox.html

Vlad
A: 

No, this is not possible. The height and width of an Image object are fixed at the time the Image object is constructed. This limitation exists in the underlying GDI+ API.

If you do not need to modify the Image, perhaps it is acceptable to scale it every time it is rendered. For example, in a Control.Paint event, you can use Graphics.DrawImage to render it directly onto the PaintEventArgs.Graphics context. This will allow you to draw the image at different sizes without creating additional Image objects.

binarycoder
I'm with you that once created an Image object, it cannot be changed, so it will always need another image to copy to the resized image.
Limo Wan Kenobi
A: 

If your reason is a problem of Memory or something like that (very large image). You could try to open it and resize it using Aforge.

Limo Wan Kenobi
A: 

You can use Matrix to resize image. you must create a matrix and scale it and set it to your Graphics object.

Matrix mx = new Matrix();
mx.Scale(2.0f,2.0f);
graphics.Transform=mx;
graphics.DrawImage(...);
Navid Farhadi