That doesn't quite cover it though.
the brush in xps also has a viewbox which is the area of the source image to pass through to the viewport.
if you crop an image in word and then print the document to xps the cropped image will be there in full with a viewbox that starts at a non 0,0 point.
I found changing the bbox and first transform could cope with that, however there was always a pixel or so wrapping around. I hardcoded a fix for now but it suggests I'm doing this wrong somehow. changing the code to the following works with an xps with an offset viewbox, but anyone know how this should be done?
Code:
PdfTilingPattern BuildPattern(ImageBrush brush, XMatrix transform)
{
// Bounding box lays always at (0,0) <-- Nope! it follows the viewbox
XRect bbox = new XRect(brush.Viewbox.X, brush.Viewbox.Y, brush.Viewbox.Width, brush.Viewbox.Height);
#if true
XMatrix matrix = transform;
//change the transform to a translate since that's all this did, and add in the viewbox offset, however add 2 to avoid the dodgy pixel... I guess I'm doing this wrong
matrix.TranslatePrepend((brush.Viewport.X - brush.Viewbox.X)+2, (brush.Viewport.Y - brush.Viewbox.Y)+2);
if (brush.Transform != null)
{
...
...