Setting Image Size and Position
The Picture object's bounds specify the size and position of an image. See
Size, Position and Rotation in the Working with Shapes and Groups
chapter earlier in this Guide for more about methods for accessing and setting the bounds of a shape.
The picture is scaled to fit within the object's bounds.
For example, to set the picture size to the image's native size and center the picture on the
slide, we could use the following code:
Dimension imageSize = picture.getData().getSize();
Rectangle bounds = new Rectangle(
(int)Units.convert(imageSize.width, Units.EMU, Units.MASTER),
(int)Units.convert(imageSize.height, Units.EMU, Units.MASTER));
Dimension slideSize = presentation.getSlideFormat().getSize();
bounds.x = (slideSize.width - bounds.width) / 2;
bounds.y = (slideSize.height - bounds.height) / 2;
picture.setBounds(bounds);