All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PictureFormat.SourceRect Property

Specifies the part of the picture to display in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v21.1.Core.dll

Declaration

RectangleOffset SourceRect { get; set; }

Property Value

Type Description
RectangleOffset

An object that specifies offsets from the picture’s edges.

Remarks

Use positive values for the SourceRect property to crop a picture. The picture is stretched to keep its size. The example below crops the bottom of the picture by 30%:

Rich_PictureFormat_SourceRect_Positive

Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Add a picture to the document.
Shape picture = document.Shapes.InsertPicture(document.Range.Start, DocumentImageSource.FromFile("Picture_Dog.png"));
// Set the picture's width and height.
picture.Width = 2.5f;
picture.Height = 1.8f;
// Crop the bottom of the picture by 30%.
picture.PictureFormat.SourceRect = new RectangleOffset(0f, 0f, 0f, 0.3f);

If the SourceRect property values are negative, empty spaces appear at the picture’s edges. The example below displays blank bands of equal width (10% of the picture width) on the left and right sides of the picture.

Rich_PictureFormat_SourceRect_Negative

Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Add a picture to the document.
Shape picture = document.Shapes.InsertPicture(document.Range.Start, DocumentImageSource.FromFile("Picture_Dog.png"));
// Set the picture's width and height.
picture.Width = 2.5f;
picture.Height = 1.8f;
// Reduce the picture size to add empty spaces to its left and right edges.
picture.PictureFormat.SourceRect = new RectangleOffset(-0.1f, 0f, -0.1f, 0f);
See Also