Skip to main content

PictureShape Class

A shape that displays a picture.

Declaration

public class PictureShape extends FilledShape

Remarks

To insert a picture, do the following:

  1. Create a PictureShape.
  2. Assign the picture using the PictureShape.setImage() method.
  3. Add the shape to the slide.

The following code snippet loads an image from a file, creates a PictureShape, configures its size and position, and adds it to a slide.

 Create a Picture Shape, DevExpress Presentation API for Java

import com.devexpress.docs.*;
import com.devexpress.docs.presentation.*;
import java.io.*;

// Create a presentation.
try(Presentation presentation = new Presentation()) {
    // Get the first slide.
    Slide slide = presentation.getSlides().getFirst();

    // Create a new PictureShape.
    PictureShape pictureShape = new PictureShape();

    // Load image data from a file.
    try(
            FileInputStream stream = new FileInputStream("images/devexpress-logo.png");
            DXImage image = DXImage.fromStream(stream);
    ) {

        pictureShape.setImage(new OfficeImage(image));
    }

    // Set the width, height, and X-Y-coordinates of the picture (in document units).
    pictureShape.setWidth(250);
    pictureShape.setHeight(250);
    pictureShape.setX(40);
    pictureShape.setY(40);

    // Add the picture shape to the slide's shape collection.
    slide.getShapes().add(pictureShape);

    // Your additional implementation goes here.
}

Refer to the following help topic for additional information: Work with Shapes — Presentation API for Java.

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Constructors

PictureShape() Constructor

Initializes a new instance of the PictureShape class.

Declaration

public PictureShape()

PictureShape(DXImage image, RectangleF rect) Constructor

Initializes a new instance of the PictureShape class with specified settings.

Declaration

public PictureShape(DXImage image, RectangleF rect)

Parameters

Name Type Description
image DXImage

The image used to initialize the picture shape.

rect RectangleF

Picture shape bounds.

PictureShape(DXImage image) Constructor

Initializes a new instance of the PictureShape class with specified settings.

Declaration

public PictureShape(DXImage image)

Parameters

Name Type Description
image DXImage

The image used to initialize the picture shape.

PictureShape(float x, float y, float width, float height) Constructor

Initializes a new instance of the PictureShape class with specified settings.

Declaration

public PictureShape(float x, float y, float width, float height)

Parameters

Name Type Description
x float

The horizontal position of the picture shape.

y float

The vertical position of the picture shape.

width float

The width of the picture shape.

height float

The height of the picture shape.

PictureShape(OfficeImageBase image, float x, float y, float width, float height) Constructor

Initializes a new instance of the PictureShape class with specified settings.

Declaration

public PictureShape(OfficeImageBase image, float x, float y, float width, float height)

Parameters

Name Type Description
image OfficeImageBase

The image used to initialize the picture shape.

x float

The horizontal position of the picture shape.

y float

The vertical position of the picture shape.

width float

The width of the picture shape.

height float

The height of the picture shape.

PictureShape(RectangleF rect) Constructor

Initializes a new instance of the PictureShape class with specified settings.

Declaration

public PictureShape(RectangleF rect)

Parameters

Name Type Description
rect RectangleF

Picture shape bounds.

Methods

deepClone() Method

Clones the current PictureShape instance.

Declaration

public PictureShape deepClone()

Returns

Type Description
PictureShape

The cloned PictureShape instance.

getCropBottom() Method

Returns the percentage of the picture cut off at the bottom.

Declaration

public float getCropBottom()

Returns

Type Description
float

The percentage of the picture cut off at the bottom.

getCropLeft() Method

Returns the percentage of the picture cut from the left.

Declaration

public float getCropLeft()

Returns

Type Description
float

The percentage of the picture cut off at the left.

getCropRight() Method

Returns the percentage of the picture cut off at the right.

Declaration

public float getCropRight()

Returns

Type Description
float

The percentage of the picture cut off at the right.

getCropTop() Method

Returns the percentage of the picture cut off at the top.

Declaration

public float getCropTop()

Returns

Type Description
float

The percentage of the picture cut off at the top.

getImage() Method

Returns the image displayed in the PictureShape.

Declaration

public OfficeImageBase getImage()

Returns

Type Description
OfficeImageBase

The image displayed in the PictureShape, or null if no image is assigned.

getLockSettings() Method

Returns shape lock settings. Lock settings restrict user operations or hide certain visual elements.

Declaration

public PictureLockSettings getLockSettings()

Returns

Type Description
PictureLockSettings

Contains lock settings.

getType() Method

Returns the shape type.

Declaration

public ShapeType getType()

Returns

Type Description
ShapeType

The shape type.

setCropBottom(float value) Method

Sets the percentage of the picture cut off at the bottom.

Declaration

public void setCropBottom(float value)

Parameters

Name Type Description
value float

The percentage of the picture cut off at the bottom.

setCropLeft(float value) Method

Sets the percentage of the picture cut from the left.

Declaration

public void setCropLeft(float value)

Parameters

Name Type Description
value float

The percentage of the picture cut off at the left.

setCropRight(float value) Method

Sets the percentage of the picture cut off at the right.

Declaration

public void setCropRight(float value)

Parameters

Name Type Description
value float

The percentage of the picture cut off at the right.

setCropTop(float value) Method

Sets the percentage of the picture cut off at the top.

Declaration

public void setCropTop(float value)

Parameters

Name Type Description
value float

The percentage of the picture cut off at the top.

setImage(DXImage image) Method

Sets the image displayed in the PictureShape.

Declaration

public void setImage(DXImage image)

Parameters

Name Type Description
image DXImage

The image to display in the shape; null to remove the image.

setImage(OfficeImageBase image) Method

Sets the image displayed in the PictureShape.

Declaration

public void setImage(OfficeImageBase image)

Parameters

Name Type Description
image OfficeImageBase

The image to display in the shape; null to remove the image.

setType(ShapeType value) Method

Sets the shape type.

Declaration

public void setType(ShapeType value)

Parameters

Name Type Description
value ShapeType

The shape type.