我正在尝试在 windows phone 中获取图像的高度和宽度...但是几乎没有语法错误
我该怎么做?
int hight = image1.ActualHeight;
int width = image1.ActualWidth;
BitmapImage img = new BitmapImage(image1.Image);
BitmapImage newImg = new BitmapImage(hight,width);
我正在尝试在 windows phone 中获取图像的高度和宽度...但是几乎没有语法错误
我该怎么做?
int hight = image1.ActualHeight;
int width = image1.ActualWidth;
BitmapImage img = new BitmapImage(image1.Image);
BitmapImage newImg = new BitmapImage(hight,width);
要创建图像,
<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;
希望这可以消除您的疑问