打开 xml 从 .pptx 文件获取图像
我有一个 .Net 4.0 中的 Windows 窗体应用程序。我用 C# 工作。 我想从 .pptx 文件中的给定幻灯片中获取图像。
此代码获取幻灯片上的每个图像:
public static SlidePart GetSlidePart(PresentationDocument presentationDocument, int slideIndex)
{
if (presentationDocument == null)
{
throw new ArgumentNullException("presentationDocument", "GetSlidePart Method: parameter presentationDocument is null");
}
int slidesCount = CountSlides(presentationDocument);
if (slideIndex < 0 || slideIndex >= slidesCount)
{
throw new ArgumentOutOfRangeException("slideIndex", "GetSlidePart Method: parameter slideIndex is out of range");
}
PresentationPart presentationPart = presentationDocument.PresentationPart;
if (presentationPart != null && presentationPart.Presentation != null)
{
Presentation presentation = presentationPart.Presentation;
if (presentation.SlideIdList != null)
{
var slideIds = presentation.SlideIdList.ChildElements;
if (slideIndex < slideIds.Count)
{
string slidePartRelationshipId = (slideIds[slideIndex] as SlideId).RelationshipId;
SlidePart slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId);
return slidePart;
}
}
}
return null;// No slide found
}
但是,如何将 slipPart 转换为将在我的 Windows 窗体中显示的图像(在 imageList 或类似的东西中)?
I have a Windows forms app in .Net 4.0. I work in C#.
I want to grab an image from a given slide in a .pptx file.
This code gets every image on the slide:
public static SlidePart GetSlidePart(PresentationDocument presentationDocument, int slideIndex)
{
if (presentationDocument == null)
{
throw new ArgumentNullException("presentationDocument", "GetSlidePart Method: parameter presentationDocument is null");
}
int slidesCount = CountSlides(presentationDocument);
if (slideIndex < 0 || slideIndex >= slidesCount)
{
throw new ArgumentOutOfRangeException("slideIndex", "GetSlidePart Method: parameter slideIndex is out of range");
}
PresentationPart presentationPart = presentationDocument.PresentationPart;
if (presentationPart != null && presentationPart.Presentation != null)
{
Presentation presentation = presentationPart.Presentation;
if (presentation.SlideIdList != null)
{
var slideIds = presentation.SlideIdList.ChildElements;
if (slideIndex < slideIds.Count)
{
string slidePartRelationshipId = (slideIds[slideIndex] as SlideId).RelationshipId;
SlidePart slidePart = (SlidePart)presentationPart.GetPartById(slidePartRelationshipId);
return slidePart;
}
}
}
return null;// No slide found
}
But, how to convert slidePart to an image which will be shown in my Windows form (in imageList or something similar)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个办法:
Found a way: