Drawing — Aspose.Slides FOSS for Java API Reference
Aspose.Slides FOSS for Java provides several drawing-related utility types for working with images and geometric points.
Package: org.aspose.slides.foss
import org.aspose.slides.foss.*;Images (Factory)
The Images class provides static factory methods to create IImage instances.
public class ImagesMethods
| Method | Returns | Description |
|---|---|---|
Images.fromFile(String path) | IImage | Load an image from a file path. |
Images.fromStream(InputStream stream) | IImage | Load an image from an input stream. |
Images.fromBytes(byte[] data) | IImage | Create an image from a byte array. |
Image (IImage)
The Image class represents a decoded image. It implements IImage.
Properties
| Property | Type | Description |
|---|---|---|
getWidth() | int | Image width in pixels. |
getHeight() | int | Image height in pixels. |
getContentType() | String | MIME content type. |
PPImage (IPPImage)
The PPImage class represents an image embedded in a presentation. It implements IPPImage.
Properties
| Property | Type | Description |
|---|---|---|
getImage() | IImage | The underlying image data. |
getContentType() | String | MIME content type. |
PointF
The PointF class represents a point with float coordinates, used for comment positions.
Constructor
| Signature | Description |
|---|---|
PointF(float x, float y) | Creates a point at (x, y). |
Properties
| Property | Type | Description |
|---|---|---|
getX() | float | X coordinate. |
getY() | float | Y coordinate. |
Usage Examples
Load and Embed an Image
import org.aspose.slides.foss.*;
Presentation prs = new Presentation();
IImage img = Images.fromFile("photo.png");
IPPImage ppImg = prs.getImages().addImage(img);
ISlide slide = prs.getSlides().get(0);
slide.getShapes().addPictureFrame(
ShapeType.RECTANGLE, 50, 50, 300, 200, ppImg);
prs.save("with-image.pptx", SaveFormat.PPTX);