Resize image and change background Color

2019-09-10 09:55发布

问题:

I finish from resizing image but how can I change Background Color (Change black Color)?

Like this image:

http://i.stack.imgur.com/2Y3xG.jpg

 BitmapImage img = new BitmapImage();
 img.SetSource(e.ChosenPhoto);
 Image image2 = new Image()
 {
     Width=640,Height=640,Visibility=Visibility.Collapsed,Source=img
 };

 WriteableBitmap wb1 = new WriteableBitmap(image2,st);

 wb1.SaveJpeg(ms1, 640, 640, 0, 100);

回答1:

you must place your Image control inside a container control (like a grid) and change the background color of that container.