Reputation: 129
I am trying to get the height and width of an image in windows phone...but there are few syntax errors
how should i do this?
int hight = image1.ActualHeight;
int width = image1.ActualWidth;
BitmapImage img = new BitmapImage(image1.Image);
BitmapImage newImg = new BitmapImage(hight,width);
Upvotes: 2
Views: 1704
Reputation: 5557
To create an image,
<Image x:Name="image1" Source="myPicture.png" />
And then you can access it in your code behind
double height = image1.ActualHeight;
double width = image1.ActualWidth;
And there is no constructor for BitmapImage class which takes the arguments that you are passing. You can create a new BitmapImage in either of the following ways
BitmapImage bmp = new BitmapImage(new Uri("myPicture.jpg", UriKind.RelativeOrAbsolute));
or
BitmapImage bmp = new BitmapImage();
bmp.UriSource = new Uri("myPicture.jpg", UriKind.RelativeOrAbsolute);
or
BitmapImage bitmapImage = image1.Source as BitmapImage;
Hope this clears your doubt
Upvotes: 3