0

I have Image and i have created visual brush for image when i move object form one point to another. but I don't see image on visual brush. if you see my rectangle, it suppose to show image.

See image : http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/e8833983-3d73-45e1-8af1-3bc27846441d

here is code:

internal static VisualBrush GetVisualBrushByObject(LabelObject obj, Rect objectRect, int quality, FlowDirection flowdirection)
    {
        DrawingVisual drawingVisual = new DrawingVisual();
        DrawingContext drawingContext = drawingVisual.RenderOpen();
        Rect objectbounds = new Rect(0, 0, objectRect.Width, objectRect.Height);
        if (obj is TextObject)
        {
            TextObject txtObj = obj.Clone() as TextObject;
            DymoTextBlock txtBlock = txtObj.DymoTextBlock as DymoTextBlock;
            objectbounds = new Rect(txtBlock.GetNaturalSize(txtBlock.GetFormattedText(flowdirection)));
        }
        if (obj is ImageObject)
        {
            drawingContext.DrawImage(((ImageObject)obj).Image, objectbounds);
        }

        LabelObject.RenderParams lrp = new LabelObject.RenderParams(drawingContext, new Common.Resolution(96, 96), false, objectbounds, flowdirection);
        obj.Render(lrp);

        VisualBrush vBrush = new VisualBrush();
        vBrush.TileMode = TileMode.None;
        vBrush.Stretch = Stretch.Fill;
        if (obj is ImageObject)
        {
            vBrush.Opacity = 0.4;
        }
        drawingContext.Close();

        vBrush.Visual = drawingVisual;

        return vBrush;
    }

pls help me

Thanks

user1535848
  • 149
  • 1
  • 2
  • 9

1 Answers1

0

If you are moving your image with Transforms(TranslateTransform), then you have to undo it for the visual brush phase.

Erti-Chris Eelmaa
  • 25,338
  • 6
  • 61
  • 78