Questions tagged [drawingcontext]
75 questions
17
votes
4 answers
Rendering into a custom DrawingContext
I'd like to hijack the usual WPF rendering to split the controls into primitives, do the layout management, apply the bindings etc. for me.
As far as I understand, the whole rendering in WPF boils down to rendering of primitives (text, image, line,…

Vlad
- 35,022
- 6
- 77
- 199
10
votes
3 answers
DrawingContext to Bitmap file
I have a DrawingContext (part of a Visual or a DrawingGroup), where I draw a bunch of rectangles and/or 1-bit images on top of each other. Think of it as a masking 1-bit image. I would like to convert this into a bitmap image file.
Using…

LadderLogic
- 1,090
- 9
- 17
8
votes
2 answers
How to apply a drop shadow effect when drawing to a DrawingContext in WPF?
I'm drawing into a DrawingContext, and I'd like to apply a drop shadow effect to part of the drawing. At the moment I create the relevant parts in a DrawingGroup and apply a BitmapEffect, but this has no effect:
var layer = new DrawingGroup();
using…

Roman Starkov
- 59,298
- 38
- 251
- 324
8
votes
1 answer
WPF MouseMove InvalidateVisual OnRender update VERY SLOW
I haven't found anything useful either on Google or Stack Overflow or simply no answers (or maybe I just don't know what to search for) -- the closest question I can get to is this one: The reason behind slow performance in WPF
But I want to get to…

pm101
- 1,309
- 10
- 30
8
votes
2 answers
When do adjustsFontSizeToFitWidth or boundingRectWithSize change the context.actualScaleFactor?
When does the actualScaleFactor of an NSStringDrawingContext change?
The documentation says:
"If you specified a custom value in the minimumScaleFactor property, when drawing is complete, this property contains the actual scale factor value that was…

RanLearns
- 4,086
- 5
- 44
- 81
6
votes
1 answer
StreamGeometry vs DrawingContext.DrawLine in WPF C#
I'm going to draw hundreds of lines in real-time. I have chosen the Visual Layer to do this. But I see that there are two different ways to draw a line here. Which one you suggest to get a better performance and speed?
1.…

Vahid
- 5,144
- 13
- 70
- 146
6
votes
1 answer
Performance of WriteableBitmap(Ex) vs DrawingContext
I am building a custom UI framework in WPF where I basically ditch as much of the built-in layout system and controls as I can. So far I have been branching off from UIElement directly, but since I am already doing the measure, arrange and rendering…

d7samurai
- 3,086
- 2
- 30
- 43
6
votes
2 answers
Rendering drawingvisuals fast in WPF
Currently I have an image on a canvas that can I freely move around in my application on which I have 6 layers of DrawingVisuals rendered, but it seems to be pretty slow. I'm using a RenderTargetBitmap to render the visuals on. Is there a faster way…

Lord Gamez
- 299
- 7
- 15
5
votes
1 answer
Display a DrawingVisual on Canvas
I have a drawing visual which I have drawings, how do I add this to my canvas and display?
DrawingVisual drawingVisual = new DrawingVisual();
// Retrieve the DrawingContext in order to create new drawing content.
DrawingContext drawingContext =…

Joga
- 235
- 3
- 11
5
votes
1 answer
Improving DrawingContext performance rendering Geometry (Polygons and Polylines)
this is my first question, however I'm a long time lurker. I'll split up this into two parts, one part explaining what I'm doing and why I think this is the way to go, the second one being the actual question that I can't solve for myself.
What am I…

Simon
- 428
- 5
- 19
5
votes
4 answers
DrawingContext.DrawLine: Pen has no full opacity?
when I draw something like that (just random drawings here):
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DrawingVisual visual = new DrawingVisual();
DrawingContext context…

Julian
- 265
- 5
- 10
4
votes
1 answer
DrawingContext adorner - possible to draw stackpanel?
Using the DrawingContext class I've been able to use the DrawRectangle() method to successfully add an adorner to my adornedElement.
Is it possible to construct a stackpanel, with a textbox and image inside - and assign this as the adorner?
I'm…
user1017882
4
votes
1 answer
How to draw an exact 1 monitor pixel line using drawingContext in OnRender for a 120 DPI resolution?
I just cannot manage to draw a single pixel wide black (!) line in OnRender using drawingContext.DrawLine() on my laptop monitor which has a DPI of 120. I face this problems since years and I read many answers here on stackoverflow, but I can simply…

Peter Huber
- 3,052
- 2
- 30
- 42
4
votes
1 answer
WPF DrawingContext: How to keep existing content when draw new content?
I have a DrawingVisual and want to draw a grape tree, show to screen then after that, draw a fox. Like this:
public class Gif : DrawingVisual
{
void Draw_Geometry(Geometry geo)
{
using (DrawingContext dc = RenderOpen())
{
…

NoName
- 7,940
- 13
- 56
- 108
4
votes
1 answer
Blurry Transformed Text in WPF
I'm using DrawingContext.DrawText and DrawingContext.PushTransfrom to create rotated text on Visual Layer in WPF but as you see in the image below, the rotated text is rather blurry in some areas of the image..
Is there any option I can use to…

Vahid
- 5,144
- 13
- 70
- 146