You are trying to assign the Control
"image1" to a WriteableBitmap
object, that's why you have an error (they are 2 different types).
You should initialize the WriteableBitmap
differently, depending on how the source of "image1" was set.
If "image1" references a local image, you can initialize the corresponding WriteableBitmap
that way:
BitmapImage img = new BitmapImage(new Uri(@"images/yourimage.jpg", UriKind.Relative));
img.CreateOptions = BitmapCreateOptions.None;
img.ImageOpened += (s, e) =>
{
WriteableBitmap wr = new WriteableBitmap((BitmapImage)s);
};
If you want to render your Image control into a WriteableBitmap, you can do that:
WriteableBitmap wr = new WriteableBitmap(image1, null);