0

嗨,我使用 apache poi 构建了一个 powerpoint 演示文稿,并在演示文稿中添加了很多图像。

private void addImage(SlideShow slideShow, Sheet slide, File image, int x, int y, int w, int h) {
    try {
        int idx = slideShow.addPicture(image, Picture.JPEG);
        Picture pict = new Picture(idx);
        pict.setAnchor(new Rectangle(x, y, w, h));
        slide.addShape(pict);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

该功能有效,最后我得到了一个 ppt 演示文稿,但是 ppt 文件太大,在另一台 PC 上我得到一个堆空间错误。所以我想调整/压缩幻灯片中的图像。我在每张幻灯片上有四张图片 - 因此它们不需要具有原始分辨率。

poi中是否有内置函数来执行此操作?就像是

pict.resize(width, height);

我正在使用 apache poi 3.7

提前谢谢

4

1 回答 1

2

POI 不会修改图片数据本身。您需要自己重新采样

于 2013-10-25T13:47:14.900 回答