Questions tagged [drawingvisual]

DrawingVisual is a visual object that can be used to render vector graphics on the screen. It's part of the Microsoft .NET Framework 3.0+.

DrawingVisual is a lightweight drawing class that is used to render shapes, images, or text. This class is considered lightweight because it does not provide layout, input, focus, or event handling, which improves its performance. For this reason, drawings are ideal for backgrounds and clip art.

DrawingVisual part of the Microsoft .NET Framework 3.0+.

44 questions
42
votes
5 answers

Fast 2D graphics in WPF

I need to draw a large amount of 2D elements in WPF, such as lines and polygons. Their position also needs to be updated constantly. I have looked at many of the answers here which mostly suggested using DrawingVisual or overriding the OnRender…
morishuz
  • 2,302
  • 4
  • 21
  • 21
15
votes
3 answers

The reason behind slow performance in WPF

I'm creating a large number of texts in WPF using DrawText and then adding them to a single Canvas. I need to redraw the screen in each MouseWheel event and I realized that the performance is a bit slow, so I measured the time the objects are…
Vahid
  • 5,144
  • 13
  • 70
  • 146
9
votes
3 answers

Windows update KB4040972/73 causes black images with WPF classes

I have an application relying on Deep zoom images (convertion from a PNG to a pyramid of JPGs in various scale) which we use DeepZoomTools.dll for. This is relying on PresentationCore.dll and has been working fine for years. After the rollout of…
Johan
  • 305
  • 1
  • 11
6
votes
0 answers

RenderTargetBitmap is always anti-aliasing my DrawingVisual

I have to render the text from a TextBox into a WriteableBitmap. This code is working pretty well but the text in it is blurry or anti-aliased. Any ideas on how to keep it aliased and crisp? text = new FormattedText(tb.Text, new…
5
votes
1 answer

Dynamically add Columns to DataGrid in wpf

I am currently working on a custom canvas and in that i have to add a table,So i thought dataGrid would be fine. SO i Want to create a "Table" from "Datagrid" by which user can add a table to the canvas at runtime. Till now, I have tried to…
Abhinav
  • 75
  • 1
  • 1
  • 11
4
votes
0 answers

WPF DrawingVisual performance on some machines

I am developing an application which needs to draw around 70k rectangles in form of a grid (one grid 40x250 and one 250x250). Not all rectangles will be visible on a screen at the time. After reading…
aadam
  • 713
  • 5
  • 18
4
votes
1 answer

DrawText at an angle in DrawingContext?

So I am using the following code to take an existing image, text from an input form, and then place the text from the input form onto the existing image and save it as a new image: using (FileStream output = new FileStream(match_outputFile,…
Jason Axelrod
  • 7,155
  • 10
  • 50
  • 78
3
votes
0 answers

RenderTargetBitmap : Impossible to free/dispose handle

Sorry for my bad english. I want to render a DrawingVisual to a bitmap so I can create a DiffuseMaterial. I do this: public DiffuseMaterial GetDiffuseMaterial(string text, string font, double fontSize, Brush brush) { FormattedText formattedText…
steacker
  • 127
  • 1
  • 10
3
votes
1 answer

Changing the text of a FormattedText

I'm using the following method to write text to my MainWindow. My question is, is there any way to change the Text of the FormattetText or the drawingvisual after it has been created? Or should I use another method to write my text, if I want it…
user602996
3
votes
1 answer

DrawingVisual not showing in WPF Canvas inside a Window

I created a minimal project in order to "get going" with drawing with DrawingVisuals in WPF (being very beginner so far). My project contains only XAML and code behind for the main window. The only purpose of this project is open a window and…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
3
votes
0 answers

BitmapCacheBrush - release Visual after cached?

I am evaluating WPF for use in an application which will need to render tens of thousands of elements (rectangles, lines, circles). The rendering needs to be fast but can be done once and cached - so I've found BitmapCacheBrush is the recommended…
AnonDev
  • 172
  • 3
  • 7
3
votes
2 answers

How do I convert DrawingVisual to a Bitmap?

Using Visual C# 2010, I'm trying to write an .avi file from frames received from a Windows Kinect. The frames can be saved easily enough as .png files with the use of a BitmapEncoder and PngBitmapEncoder (saving to a stream) but I can't add these…
Duncan Davey
  • 31
  • 1
  • 3
2
votes
1 answer

How to draw something in DrawingVisual with millimeter unit instead of pixels?

I'm trying to draw something in a System.Windows.Media.DrawingVisual but I need to draw thins in millimeter unit. How can I do that?
ahmadali shafiee
  • 4,350
  • 12
  • 56
  • 91
2
votes
1 answer

Displaying Both VisualCollection and UIElements

I'm using a VisualCollection to display custom DrawingVisuals on a Canvas in WPF, and I also need the canvas to display a couple of UIElements. The problem is that the canvas seems to ignore its regular children when using a VisualCollection. The…
Simon
  • 191
  • 2
  • 8
2
votes
0 answers

WPF Cropping an imagesource in DrawingVisual

I need to display a cropped region of an image source within a DrawingVisual, but for the past few hours I've just drawn blanks for what should be a simple task. My plan is to implement timed animation (for a HMI system) which will take a big image…
Muckers Mate
  • 399
  • 8
  • 23
1
2 3