OpenOffice Drawing API:从页面大小的图片创建幻灯片

发布于 2024-11-24 09:48:31 字数 370 浏览 3 评论 0原文

我从一系列图像文件创建了一个 Impress 演示文稿。我可以创建一个 Page 并插入 GraphicObjectShape ,没有任何问题,但当我必须调整包含图像的形状的大小时,我遇到了困难。

我的问题是我不知道应该使用什么尺寸。当然,我可以进行反复试验,但这不会很专业,不是吗?

我的问题:我创建的新页面的大小以像素为单位?如何访问图片上下文菜单中的“原始尺寸”功能?

在页面设置中,我看到尺寸为 11.02" x 8.27" - 当我创建新文档和新页面时,是否可以保证所有未来版本都将使用此尺寸?

了解图像文件的大小应该适合整个页面会很有趣。

I create an Impress presentation from a series of image files. I can create a Page and insert the GraphicObjectShape without any problem, but got stuck when I have to size the shape containing the image.

My problem is that I have no clue what sizes should I use. Of course I could go with a trial and error process, but it would not be very professional would it?

My questions: what is the size of the new Page I create in pixels? How to access the function "Original Size" which can be found in the picture's context menu?

In the Page Setup I see a size of 11.02" x 8.27" - Is there any guarantee that all future versions will use this size when I create a new document and a new page within?

It would be interesting to know what size the image file should be to fit the whole page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-12-01 09:48:31

光栅图像似乎以 96 DPI 分辨率加载。如果您使用 Impress 的默认页面尺寸 (11.02" x 8.27"),则完全适合的光栅图像尺寸(以像素为单位)为:

1058 x 794

另外,如果您坚持使用此尺寸(如它可能是最兼容的选择(例如,当您保存到 PPT 时),不要依赖这是默认值这一事实。创建文档后,您可以通过设置任何页面的 WidthHeight 属性来设置幻灯片的大小(似乎在调整某个页面的大小后,所有其他页面都会跟随)其中)。

API 使用 100/mm 刻度。 11.02 英寸为 280 毫米,因此宽度为 280 * 100 = 28000,高度为 21000。

将演示文稿大小调整为 11.02" x 8.27" 并插入(最好是 4:3)图像以适合的 Java 示例整个页面:

XDrawPage page;
XMultiServiceFactory factory;

// ... setting up the environment and opening document

// resize the page (and all other pages) to our default size
XPropertySet pagePropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, page);
pagePropSet.setPropertyValue("Width", 28000);
pagePropSet.setPropertyValue("Height", 21000);

// create GraphicObjectShape with the size of the page in the top-left corner
Object picture = factory.createInstance("com.sun.star.drawing.GraphicObjectShape");
XShape pictureShape = (XShape)UnoRuntime.queryInterface(XShape.class, picture);
pictureShape.setSize(new Size(28000, 21000));
pictureShape.setPosition(new Point(0, 0));

// load the image file into our the shape
XPropertySet propSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, pictureShape);
propSet.setPropertyValue("GraphicURL", new File("c:\\Users\\Vbence\\Downloads\\slide.png").toURI().toURL().toString());

// add the shape to the page
page.add(pictureShape);

It seems that raster images are loaded with a 96 DPI resolution. If you are using the default page size for Impress (11.02" x 8.27") then the fully fitting raster image size (in pixels) is:

1058 x 794

Also, if you stick with this size (as it is probably the most compatible choice for example when you are saving to PPT), do not rely on the fact that this is the default. After document is created you can set the size of the slides by setting the Width and Height property of any page (it seems that all other pages going to follow after you resize one of them).

The API uses a 100/mm scale. 11.02 iches are 280 mm, so width is 280 * 100 = 28000, height is 21000.

Java example to resize the presentaion to 11.02" x 8.27" and insert (a preferably 4:3) image to fit the whole page:

XDrawPage page;
XMultiServiceFactory factory;

// ... setting up the environment and opening document

// resize the page (and all other pages) to our default size
XPropertySet pagePropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, page);
pagePropSet.setPropertyValue("Width", 28000);
pagePropSet.setPropertyValue("Height", 21000);

// create GraphicObjectShape with the size of the page in the top-left corner
Object picture = factory.createInstance("com.sun.star.drawing.GraphicObjectShape");
XShape pictureShape = (XShape)UnoRuntime.queryInterface(XShape.class, picture);
pictureShape.setSize(new Size(28000, 21000));
pictureShape.setPosition(new Point(0, 0));

// load the image file into our the shape
XPropertySet propSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, pictureShape);
propSet.setPropertyValue("GraphicURL", new File("c:\\Users\\Vbence\\Downloads\\slide.png").toURI().toURL().toString());

// add the shape to the page
page.add(pictureShape);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文