Share via


IXpsOMTileBrush::SetViewbox method

Sets the portion of the source content to be used as the tile image.

Syntax

HRESULT SetViewbox(
  [in] const XPS_RECT *viewbox
);

Parameters

  • viewbox [in]
    An XPS_RECT structure that describes the portion of the source content to be used as the tile image.

Return value

The method returns an HRESULT. Possible values include, but are not limited to, those in the table that follows. For information about XPS document API return values that are not listed in this table, see XPS Document Errors.

Return code Description
S_OK

The method succeeded.

E_POINTER

viewbox is NULL.

E_INVALIDARG

The rectangle described in viewbox was not valid.

 

Remarks

The brush's viewbox specifies the portion of a source image or visual to be used as the tile image.

The coordinates of the brush's viewbox are relative to the source content, such that (0,0) specifies the upper-left corner of the source content. For images, dimensions specified by the brush's viewbox are expressed in the units of 1/96". The corresponding pixel coordinates in the source image are calculated as follows:

SourceLeft = HorizontalImageResolution * viewbox.x / 96

SourceTop = VerticalImageResolution * viewbox.y / 96

SourceWidth = HorizontalImageResolution * viewbox.width / 96

SourceHeight = VerticalImageResolution * viewbox.height / 96

In the illustration that follows, the image on the left is an example of a source image, while that on the right is the source image with the selected viewbox for the brush shown as a red rectangle. In this example, the part of the source image that is used as the content for the tile brush is the area within the red rectangle. The shaded area of the image is not used by the brush.

An image that shows how a viewbox is mapped to a source image

If the source image resolution is 96 by 96 dots per inch and image dimensions are 96 by 96 pixels, the values of fields in the viewbox parameter would be:

viewbox.x = 48

viewbox.y = 24

viewbox.width = 24

viewbox.height = 48

The preceding parameter values correspond to the source image as:

SourceLeft = 96 * 48 / 96 = 48 pixels from the left side

SourceTop = 96 * 24 / 96 = 24 pixels from the top

SourceWidth = 96 * 24 / 96 = 24 pixels wide

SourceHeight = 96 * 48 / 96 = 48 pixels high

Requirements

Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps]

Header

Xpsobjectmodel.h

IDL

XpsObjectModel.idl

See also

IXpsOMTileBrush

XPS_RECT

XPS Document Errors

XML Paper Specification