3
我深化发展一个愚蠢的应用程序: - 打开从媒体库, 一个图片 - 放在一个网格单元所选择的图像(其中包含TextBlok元素) - 保存“保存的图片”相册中的图片。WP7如何适应网格尺寸图像尺寸
我的XAML代码:
<controls:PanoramaItem Header="Image Selection" Height="652">
<Grid Name="markedImage" Margin="0,0,4,89">
<Image x:Name="img" Stretch="Fill" Margin="0,0,0,10"></Image>
<TextBlock x:Name="text" Text="Hello!">
<i:Interaction.Behaviors>
<el:MouseDragElementBehavior ConstrainToParentBounds="True"/>
</i:Interaction.Behaviors>
</TextBlock>
</Grid>
和代码来打开和保存所选择的图片:
private void photoChooserTask_Completed(object sender, PhotoResult e)
{
try
{
BitmapImage image = new BitmapImage();
image.SetSource(e.ChosenPhoto);
WriteableBitmap wbp = new WriteableBitmap(image);
this.img.Source = image;
height = image.PixelHeight;
width = image.PixelWidth;
MessageBox.Show("H: " + height + "\t" + "W: " + width);
}
catch
{
MessageBox.Show("Disconnect your device from Zune");
}
}
private void save_Click(object sender, System.EventArgs e)
{
WriteableBitmap marked = new WriteableBitmap(this.markedImage, null);
ThreadPool.QueueUserWorkItem(callback =>
{
MemoryStream ms = new MemoryStream();
marked.SaveJpeg(ms, (width * 2), (height * 2), 0, 100);
using (MediaLibrary lib = new MediaLibrary())
lib.SavePicture("Test", ms.ToArray());
});
MessageBox.Show("H: " + marked.PixelHeight + "\t" + "W: " + marked.PixelWidth);
// wbm.SaveToMediaLibrary("SavedPicture.jpg", true);
MessageBox.Show("Picture saved successfully");
}
,因为我是我不能发布图片新用户,无论如何图片(orignal和保存的图片)具有相同的高度和宽度,但他们看起来不同 我认为问题是网格尺寸和Stretch属性。我尝试了不同的组合,但结果并不好。 一些建议?
编辑:我赚了点声望值 原始图片是
保存的图片被
,如果你在另一个窗口同时打开,就可以看到区别
它工作的很好,这样你解决了我有关图片质量和尺寸的问题。我只是适应它来解决其他问题:) – antedesk