2012-02-29 155 views
0

我从Web上拉取图像并将其添加到FixedDocument页面。我拉的图像的尺寸大小为1200像素×1500像素。但是在FixedDocument中,图像显示为小缩略图(请参阅屏幕截图)。FixedDocument页面大小

下面给出的是代码片段。

FixedDocument fd = new FixedDocument(); 

BitmapImage bi = new BitmapImage(); 
bi.BeginInit(); 
bi.UriSource = new Uri(@"http://www.example.com/image.jpg", UriKind.Absolute); 
bi.EndInit(); 
Image i = new Image(); 
i.Source = bi; 

FixedPage fixedPage = new FixedPage(); 
fixedPage.Children.Add(i);     

PageContent pageContent = new PageContent(); 
(pageContent as IAddChild).AddChild(fixedPage); 
fd.Pages.Add(pageContent); 

我需要按照其尺寸显示图像,而不是缩略图。请有人告诉我需要做什么来显示图像的大小?

非常感谢。

enter image description here

+0

您的代码对我来说很适合[this](http://upload.wikimedia.org/wikipedia/commons/c/cd/RathausBremen-01-2.jpg)大图。您可以在[BitmapSource.DownloadCompleted](http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.downloadcompleted.aspx)事件处理程序中交叉检查图像大小,以查看是否你有你想要的。 – Clemens 2012-02-29 12:06:45

+0

@Clemens:谢谢。请将您的评论作为答案,我会接受它。正如您指出的,在DownloadCompleted事件处理程序中检查高度和宽度显示了问题。高度和宽度分别显示为150px X 225px。为什么会这样?您的评论中的链接图像已打开到完美的大小,这是服务器问题吗? – 2012-02-29 13:36:57

回答

2

你的代码对我来说工作正常this大图像。

您可以在BitmapSource.DownloadCompleted事件处理函数中检查图像大小,以查看是否得到您想要的。

虽然,我不会解释为什么图像大小会与您所期望的不同。据我所知,JPEG图像文件可以包含缩略图以便快速预览。也许你的服务器正在提供这样一个缩略图?

+0

+1为好的照片:) – tobsen 2012-03-02 20:57:21

0

您可以添加一个视框,并把图像里面。 ViewBox的大小应该是你的文档的大小减去所需的任何边距

0

尝试设置

i.Height = bi.PixelHeight; 
i.Width = bi.PixelWidth; 

这应根据所述图像的像素重新大小i