Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IXpsOMTileBrush::SetViewbox method

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


HRESULT SetViewbox(
  [inconst XPS_RECT *viewbox


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 codeDescription

The method succeeded.


viewbox is NULL.


The rectangle described in viewbox was not valid.



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


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]





See also

XPS Document Errors
XML Paper Specification



© 2018 Microsoft