Click here to Skip to main content
14,451,737 members
Rate this:
Please Sign up or sign in to vote.
I have an imagebox and I use OpenFileDialog to load a picture

After picture is loaded I have used this code because I don't know to use image already uploaded in my imagebox

I don't want to use bmp.UriSource() to load a new image like in this example

I want to use imagebox source to transform picture inside in many ways, and to update image inside

BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri("pack://application:,,,/images/pic.png");
bmp.EndInit();
TransformedBitmap myRotatedBitmapSource = new TransformedBitmap();
myRotatedBitmapSource.BeginInit();
myRotatedBitmapSource.Source = bmp;
myRotatedBitmapSource.Transform = new RotateTransform(90);
myRotatedBitmapSource.EndInit();
image_box.Source = myRotatedBitmapSource;


What I have tried:

Uri ur = new Uri(image_box.Source.ToString(), UriKind.Absolute);
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = ur;
bmp.EndInit();
TransformedBitmap myRotatedBitmapSource = new TransformedBitmap();
myRotatedBitmapSource.BeginInit();
myRotatedBitmapSource.Source = bmp;
myRotatedBitmapSource.Transform = new RotateTransform(90);
myRotatedBitmapSource.EndInit();
image_box.Source = myRotatedBitmapSource;


after second click on button I got error

i do't want to use only rotate image, i want to use more options but i don't know to reuse image and to update it in imagebox
Posted
Comments
Gerry Schmitz 4-Feb-19 19:02pm
   
Stick to loading, manipulating, then assigning to an image control.

Then manipulate again and reassign.

Whatever else you're trying to do won't work.
sz3bbylA 5-Feb-19 13:18pm
   
so, i don't know to do this , any example, link is helpfull

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100