NodeRendererBaseGetOpaqueBoundsInPixels Method (Single, Single, Single)

Calculates the opaque bounds of the shape in pixels for a specified zoom factor and resolution.

Namespace:  Aspose.Words.Rendering
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public Rectangle GetOpaqueBoundsInPixels(
	float scale,
	float horizontalDpi,
	float verticalDpi
)

Parameters

scale
Type: SystemSingle
The zoom factor (1.0 is 100%).
horizontalDpi
Type: SystemSingle
The horizontal resolution to convert from points to pixels (dots per inch).
verticalDpi
Type: SystemSingle
The vertical resolution to convert from points to pixels (dots per inch).

Return Value

Type: Rectangle
The opaque rectangle of the shape in pixels.
Remarks

This method converts OpaqueBoundsInPoints into rectangle in pixels and it is useful when you want to create a bitmap for rendering the shape with only opaque part of the shape.

Examples
Shows how to measure and scale shapes.
// Open a document that contains an OfficeMath object
Document doc = new Document(MyDir + "Office math.docx");

// Create a renderer for the OfficeMath object 
OfficeMath officeMath = (OfficeMath)doc.GetChild(NodeType.OfficeMath, 0, true);
OfficeMathRenderer renderer = new OfficeMathRenderer(officeMath);

// We can measure the size of the image that the OfficeMath object will create when we render it
Assert.AreEqual(117.0f, renderer.SizeInPoints.Width, 0.1f);
Assert.AreEqual(12.9f, renderer.SizeInPoints.Height, 0.1f);

Assert.AreEqual(117.0f, renderer.BoundsInPoints.Width, 0.1f);
Assert.AreEqual(12.9f, renderer.BoundsInPoints.Height, 0.1f);

// Shapes with transparent parts may return different values here
Assert.AreEqual(117.0f, renderer.OpaqueBoundsInPoints.Width, 0.1f);
Assert.AreEqual(14.7f, renderer.OpaqueBoundsInPoints.Height, 0.1f);

// Get the shape size in pixels, with linear scaling to a specific DPI
Rectangle bounds = renderer.GetBoundsInPixels(1.0f, 96.0f);
Assert.AreEqual(156, bounds.Width);
Assert.AreEqual(18, bounds.Height);

// Get the shape size in pixels, but with a different DPI for the horizontal and vertical dimensions
bounds = renderer.GetBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.AreEqual(156, bounds.Width);
Assert.AreEqual(27, bounds.Height);

// The opaque bounds may vary here also
bounds = renderer.GetOpaqueBoundsInPixels(1.0f, 96.0f);
Assert.AreEqual(156, bounds.Width);
Assert.AreEqual(20, bounds.Height);

bounds = renderer.GetOpaqueBoundsInPixels(1.0f, 96.0f, 150.0f);
Assert.AreEqual(156, bounds.Width);
Assert.AreEqual(31, bounds.Height);
See Also