Windows phone 7 在wp7中调整图像大小
最近,我开始创建一个社交网络WP7应用程序。在发送用户数据的web请求时,它们在回调时为用户图像提供url。我的问题是,当绑定此图像时,我会得到不同大小的图像。很难保持图像大小一致。因此,用户界面看起来很普通。我需要做什么使这个图像大小一致。编写转换器或其他解决方案。谁能帮我解决这个问题。我尝试给出宽度、高度和填充属性,但仍然得到相同的结果Windows phone 7 在wp7中调整图像大小,windows-phone-7,Windows Phone 7,最近,我开始创建一个社交网络WP7应用程序。在发送用户数据的web请求时,它们在回调时为用户图像提供url。我的问题是,当绑定此图像时,我会得到不同大小的图像。很难保持图像大小一致。因此,用户界面看起来很普通。我需要做什么使这个图像大小一致。编写转换器或其他解决方案。谁能帮我解决这个问题。我尝试给出宽度、高度和填充属性,但仍然得到相同的结果 你可以试试这个: WriteableBitmap resizedImage = new WriteableBitmap(imageToResize);//
你可以试试这个:
WriteableBitmap resizedImage = new WriteableBitmap(imageToResize);//imageToResize is BitmapImage
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf))
{
double maxHeight = newWidth;
double maxWidth = newHeight;
double scaleX = 1;
double scaleY = 1;
if (pixHt > maxHeight)
scaleY = maxHeight / pixHt;
if (pixWt > maxWidth)
scaleX = maxWidth / pixWt;
double scale = Math.Min(scaleY, scaleX);
int newWidth1 = Convert.ToInt32(pixWt * scale);
int newHeight1 = Convert.ToInt32(pixHt * scale);
resizedImage.SaveJpeg(isfs, newWidth1, newHeight1, 0, 70);
isfs.Close();
}
}
您可以试试这个:
WriteableBitmap resizedImage = new WriteableBitmap(imageToResize);//imageToResize is BitmapImage
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(fileName, FileMode.Create, isf))
{
double maxHeight = newWidth;
double maxWidth = newHeight;
double scaleX = 1;
double scaleY = 1;
if (pixHt > maxHeight)
scaleY = maxHeight / pixHt;
if (pixWt > maxWidth)
scaleX = maxWidth / pixWt;
double scale = Math.Min(scaleY, scaleX);
int newWidth1 = Convert.ToInt32(pixWt * scale);
int newHeight1 = Convert.ToInt32(pixHt * scale);
resizedImage.SaveJpeg(isfs, newWidth1, newHeight1, 0, 70);
isfs.Close();
}
}