我试图在Windows手机中获取图像的高度和宽度...但语法错误很少
我该怎么做?
int hight = image1.ActualHeight;
int width = image1.ActualWidth;
BitmapImage img = new BitmapImage(image1.Image);
BitmapImage newImg = new BitmapImage(hight,width);
答案 0 :(得分:3)
要创建图像,
<Image x:Name="image1" Source="myPicture.png" />
然后您可以在
后面的代码中访问它double height = image1.ActualHeight;
double width = image1.ActualWidth;
并且没有BitmapImage类的构造函数,它接受您传递的参数。您可以使用以下任一方式创建新的BitmapImage
BitmapImage bmp = new BitmapImage(new Uri("myPicture.jpg", UriKind.RelativeOrAbsolute));
或
BitmapImage bmp = new BitmapImage();
bmp.UriSource = new Uri("myPicture.jpg", UriKind.RelativeOrAbsolute);
或
BitmapImage bitmapImage = image1.Source as BitmapImage;
希望这能清除你的怀疑