Rendering part of large Visual object performanceCapturing a window with WPFWait for control to finish rendering/RedrawingDeep cloning objectsHow do I properly clean up Excel interop objects?Deserialize JSON into C# dynamic object?How to Sort a List<T> by a property in the objectHow do I turn a C# object into a JSON string in .NET?WPF - clone contents of container as geometryWriting to output window of Visual Studio2D Drawing Performance (GDI+ vs SlimDX)Cropping an arbitrary wpf geometryCould not find a part of the path … binroslyncsc.exe
Is there any way to keep a player from killing an NPC?
What does Deviance mean in lmer
Is “I am getting married with my sister” ambiguous?
'Us students' - Does this apposition need a comma?
Do they have Supervillain(s)?
Is "The life is beautiful" incorrect or just very non-idiomatic?
Does merkle root contain hashes of transactions from previous blocks?
Could George I (of Great Britain) speak English?
Would the Republic of Ireland and Northern Ireland be interested in reuniting?
Why doesn't 'd /= d' throw a division by zero exception?
Why is the UK so keen to remove the "backstop" when their leadership seems to think that no border will be needed in Northern Ireland?
Are there any elected officials in the U.S. who are not legislators, judges, or constitutional officers?
Did anyone try to find the little box that held Professor Moriarty and his wife after the crash?
Are the A380 engines interchangeable (given they are not all equipped with reverse)?
Why do banks “park” their money at the European Central Bank?
How do I make my image comply with the requirements of this photography competition?
Lost property on Portuguese trains
Compelling story with the world as a villain
How can I unambiguously ask for a new user's "Display Name"?
What are some interesting features that are common cross-linguistically but don't exist in English?
Why are non-collision-resistant hash functions considered insecure for signing self-generated information
How to prevent clipped screen edges on my TV, HDMI-connected?
Does Norwegian overbook flights?
Architectural feasibility of a tiered circular stone keep
Rendering part of large Visual object performance
Capturing a window with WPFWait for control to finish rendering/RedrawingDeep cloning objectsHow do I properly clean up Excel interop objects?Deserialize JSON into C# dynamic object?How to Sort a List<T> by a property in the objectHow do I turn a C# object into a JSON string in .NET?WPF - clone contents of container as geometryWriting to output window of Visual Studio2D Drawing Performance (GDI+ vs SlimDX)Cropping an arbitrary wpf geometryCould not find a part of the path … binroslyncsc.exe
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have an application that generate graphs from some input files. The user has the option to generate an image from these graphs. The graph is created using an external library that draws into a custom visual object (inherits from Canvas).
The Functionality
I created a custom functionality to create the image out of this canvas and it has worked well so far. The problem I'm having is related to its performance when the need to generate an image out of VERY large graph.
The images generated by this functionality has always been big, to be able to generate these large images I generate smaller "chunks" (configurable, but currently at 2000x2000px, larger chunks can lose quality and smaller is slower). After these "chunks" are created I merge them using another external library (this last works fine and it is really fast, the issue does not lie here).
The Issue
The problem is happening that the larger the original visual is, each chunk rendering takes longer.
The problem is that the larger the image is, each "chunk" rendering takes longer. I'll post the code here later, but I've noticed that the "RenderTargetBitmap.Render()" method when using my "DrawingVisual" (with the chunk information). As an example, this method call takes 400ms+ on my local tests where the Canvas is 74052.75px x 1119.4px; the total image creation time takes about 20 secs.
This would not be that bad, but there was a requirement where a large (MUCH larger) image has to be created and each chunk is taking 5 minutes to generate, so my estimation is that it would take about 60 days.
The Code
This is the code I'm using at each "chunk" loop. The code is modified to remove some cancellation token and progress report calls. I also added a comment to highlight the call that takes 400+ms.
for (int i = 0; i < rowCount; i++)
for (int j = 0; j < colCount; j++)
int row = i, col = j; //this is done because task start could have a modified value on call
Rect rect = new Rect(
col * maxWidth,
row * maxHeight,
col + 1 < colCount ? maxWidth :
surfaceWidth - (colCount - 1) * maxWidth,
row + 1 < rowCount ? maxHeight :
surfaceHeight - (rowCount - 1) * maxHeight);
DrawingVisual visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
VisualBrush brush = new VisualBrush(element)
Viewbox = rect,
ViewboxUnits = BrushMappingMode.Absolute,
Stretch = Stretch.None
;
dc.DrawRectangle(brush,
null,
new Rect(0, 0, rect.Width, rect.Height));
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)(rect.Width * (imgdpi / DEFAULT_DPI)),
(int)(rect.Height * (imgdpi / DEFAULT_DPI)),
imgdpi,
imgdpi,
PixelFormat);
//***********************//
//THIS IS THE CALL THAT TAKES 400+ms
//***********************//
bitmap.Render(visual);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
//... Some additional code to work with the chunk asynchronously
Things I've tried
I've tried several things:
- Calling Dispatcher.DisableProcessing: I was thinking that it could have been that the UI kept trying to update the surface while processing the chunks (althought my understanding that if it has not been modified it shouldn't be much of a problem). But this did not change the processing time.
- While creating the VisualBrush object to assign to it smaller Viewports (chunk size or bigger). The time actually increased.
- Adding CacheMode to the Canvas: The time actually increased and the image looked low resolution.
- Some additional desperate measures that made no sense haha.
Additional Information
Since I'm not completely sure how this Render functionality works internally (And I have searched for information on these, but what I've found is superficial at best) I'm not sure if the cause is the large surface or the number of controls in the surface (or a combination of both). So here is some additional information on the test case that is taking 400ms per render:
- Surface Size is: 74052.75px x 1119.4px.
- N. of Graph's Nodes: 1977.
- N. of Connectors (Arrows): 2052.
- Each Control visual is defined in the XAML using resources.
- Each Graph Node is a Filled Rectangle with a Textblock at its center.
- Each Connector is a straight line with a triangle at one of its edges.
Also, since the very large image generation is not something that will happen that often, and not to a regular user. I would not mind if the solution provided sacrifices UI responsiveness.
Notes added to clarify some concerns in the comments section
- The graph is shown on screen to the user, this can be manipulated by it.
- The "Store as Image" functionality is just an additional optional functionality to save the graph as an Image file. (This works under normal load, the speed issue happens with an unnusually large graph).
I'd appreciate any help you could provide.
Thanks!
c# wpf
|
show 8 more comments
I have an application that generate graphs from some input files. The user has the option to generate an image from these graphs. The graph is created using an external library that draws into a custom visual object (inherits from Canvas).
The Functionality
I created a custom functionality to create the image out of this canvas and it has worked well so far. The problem I'm having is related to its performance when the need to generate an image out of VERY large graph.
The images generated by this functionality has always been big, to be able to generate these large images I generate smaller "chunks" (configurable, but currently at 2000x2000px, larger chunks can lose quality and smaller is slower). After these "chunks" are created I merge them using another external library (this last works fine and it is really fast, the issue does not lie here).
The Issue
The problem is happening that the larger the original visual is, each chunk rendering takes longer.
The problem is that the larger the image is, each "chunk" rendering takes longer. I'll post the code here later, but I've noticed that the "RenderTargetBitmap.Render()" method when using my "DrawingVisual" (with the chunk information). As an example, this method call takes 400ms+ on my local tests where the Canvas is 74052.75px x 1119.4px; the total image creation time takes about 20 secs.
This would not be that bad, but there was a requirement where a large (MUCH larger) image has to be created and each chunk is taking 5 minutes to generate, so my estimation is that it would take about 60 days.
The Code
This is the code I'm using at each "chunk" loop. The code is modified to remove some cancellation token and progress report calls. I also added a comment to highlight the call that takes 400+ms.
for (int i = 0; i < rowCount; i++)
for (int j = 0; j < colCount; j++)
int row = i, col = j; //this is done because task start could have a modified value on call
Rect rect = new Rect(
col * maxWidth,
row * maxHeight,
col + 1 < colCount ? maxWidth :
surfaceWidth - (colCount - 1) * maxWidth,
row + 1 < rowCount ? maxHeight :
surfaceHeight - (rowCount - 1) * maxHeight);
DrawingVisual visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
VisualBrush brush = new VisualBrush(element)
Viewbox = rect,
ViewboxUnits = BrushMappingMode.Absolute,
Stretch = Stretch.None
;
dc.DrawRectangle(brush,
null,
new Rect(0, 0, rect.Width, rect.Height));
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)(rect.Width * (imgdpi / DEFAULT_DPI)),
(int)(rect.Height * (imgdpi / DEFAULT_DPI)),
imgdpi,
imgdpi,
PixelFormat);
//***********************//
//THIS IS THE CALL THAT TAKES 400+ms
//***********************//
bitmap.Render(visual);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
//... Some additional code to work with the chunk asynchronously
Things I've tried
I've tried several things:
- Calling Dispatcher.DisableProcessing: I was thinking that it could have been that the UI kept trying to update the surface while processing the chunks (althought my understanding that if it has not been modified it shouldn't be much of a problem). But this did not change the processing time.
- While creating the VisualBrush object to assign to it smaller Viewports (chunk size or bigger). The time actually increased.
- Adding CacheMode to the Canvas: The time actually increased and the image looked low resolution.
- Some additional desperate measures that made no sense haha.
Additional Information
Since I'm not completely sure how this Render functionality works internally (And I have searched for information on these, but what I've found is superficial at best) I'm not sure if the cause is the large surface or the number of controls in the surface (or a combination of both). So here is some additional information on the test case that is taking 400ms per render:
- Surface Size is: 74052.75px x 1119.4px.
- N. of Graph's Nodes: 1977.
- N. of Connectors (Arrows): 2052.
- Each Control visual is defined in the XAML using resources.
- Each Graph Node is a Filled Rectangle with a Textblock at its center.
- Each Connector is a straight line with a triangle at one of its edges.
Also, since the very large image generation is not something that will happen that often, and not to a regular user. I would not mind if the solution provided sacrifices UI responsiveness.
Notes added to clarify some concerns in the comments section
- The graph is shown on screen to the user, this can be manipulated by it.
- The "Store as Image" functionality is just an additional optional functionality to save the graph as an Image file. (This works under normal load, the speed issue happens with an unnusually large graph).
I'd appreciate any help you could provide.
Thanks!
c# wpf
1
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49
|
show 8 more comments
I have an application that generate graphs from some input files. The user has the option to generate an image from these graphs. The graph is created using an external library that draws into a custom visual object (inherits from Canvas).
The Functionality
I created a custom functionality to create the image out of this canvas and it has worked well so far. The problem I'm having is related to its performance when the need to generate an image out of VERY large graph.
The images generated by this functionality has always been big, to be able to generate these large images I generate smaller "chunks" (configurable, but currently at 2000x2000px, larger chunks can lose quality and smaller is slower). After these "chunks" are created I merge them using another external library (this last works fine and it is really fast, the issue does not lie here).
The Issue
The problem is happening that the larger the original visual is, each chunk rendering takes longer.
The problem is that the larger the image is, each "chunk" rendering takes longer. I'll post the code here later, but I've noticed that the "RenderTargetBitmap.Render()" method when using my "DrawingVisual" (with the chunk information). As an example, this method call takes 400ms+ on my local tests where the Canvas is 74052.75px x 1119.4px; the total image creation time takes about 20 secs.
This would not be that bad, but there was a requirement where a large (MUCH larger) image has to be created and each chunk is taking 5 minutes to generate, so my estimation is that it would take about 60 days.
The Code
This is the code I'm using at each "chunk" loop. The code is modified to remove some cancellation token and progress report calls. I also added a comment to highlight the call that takes 400+ms.
for (int i = 0; i < rowCount; i++)
for (int j = 0; j < colCount; j++)
int row = i, col = j; //this is done because task start could have a modified value on call
Rect rect = new Rect(
col * maxWidth,
row * maxHeight,
col + 1 < colCount ? maxWidth :
surfaceWidth - (colCount - 1) * maxWidth,
row + 1 < rowCount ? maxHeight :
surfaceHeight - (rowCount - 1) * maxHeight);
DrawingVisual visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
VisualBrush brush = new VisualBrush(element)
Viewbox = rect,
ViewboxUnits = BrushMappingMode.Absolute,
Stretch = Stretch.None
;
dc.DrawRectangle(brush,
null,
new Rect(0, 0, rect.Width, rect.Height));
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)(rect.Width * (imgdpi / DEFAULT_DPI)),
(int)(rect.Height * (imgdpi / DEFAULT_DPI)),
imgdpi,
imgdpi,
PixelFormat);
//***********************//
//THIS IS THE CALL THAT TAKES 400+ms
//***********************//
bitmap.Render(visual);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
//... Some additional code to work with the chunk asynchronously
Things I've tried
I've tried several things:
- Calling Dispatcher.DisableProcessing: I was thinking that it could have been that the UI kept trying to update the surface while processing the chunks (althought my understanding that if it has not been modified it shouldn't be much of a problem). But this did not change the processing time.
- While creating the VisualBrush object to assign to it smaller Viewports (chunk size or bigger). The time actually increased.
- Adding CacheMode to the Canvas: The time actually increased and the image looked low resolution.
- Some additional desperate measures that made no sense haha.
Additional Information
Since I'm not completely sure how this Render functionality works internally (And I have searched for information on these, but what I've found is superficial at best) I'm not sure if the cause is the large surface or the number of controls in the surface (or a combination of both). So here is some additional information on the test case that is taking 400ms per render:
- Surface Size is: 74052.75px x 1119.4px.
- N. of Graph's Nodes: 1977.
- N. of Connectors (Arrows): 2052.
- Each Control visual is defined in the XAML using resources.
- Each Graph Node is a Filled Rectangle with a Textblock at its center.
- Each Connector is a straight line with a triangle at one of its edges.
Also, since the very large image generation is not something that will happen that often, and not to a regular user. I would not mind if the solution provided sacrifices UI responsiveness.
Notes added to clarify some concerns in the comments section
- The graph is shown on screen to the user, this can be manipulated by it.
- The "Store as Image" functionality is just an additional optional functionality to save the graph as an Image file. (This works under normal load, the speed issue happens with an unnusually large graph).
I'd appreciate any help you could provide.
Thanks!
c# wpf
I have an application that generate graphs from some input files. The user has the option to generate an image from these graphs. The graph is created using an external library that draws into a custom visual object (inherits from Canvas).
The Functionality
I created a custom functionality to create the image out of this canvas and it has worked well so far. The problem I'm having is related to its performance when the need to generate an image out of VERY large graph.
The images generated by this functionality has always been big, to be able to generate these large images I generate smaller "chunks" (configurable, but currently at 2000x2000px, larger chunks can lose quality and smaller is slower). After these "chunks" are created I merge them using another external library (this last works fine and it is really fast, the issue does not lie here).
The Issue
The problem is happening that the larger the original visual is, each chunk rendering takes longer.
The problem is that the larger the image is, each "chunk" rendering takes longer. I'll post the code here later, but I've noticed that the "RenderTargetBitmap.Render()" method when using my "DrawingVisual" (with the chunk information). As an example, this method call takes 400ms+ on my local tests where the Canvas is 74052.75px x 1119.4px; the total image creation time takes about 20 secs.
This would not be that bad, but there was a requirement where a large (MUCH larger) image has to be created and each chunk is taking 5 minutes to generate, so my estimation is that it would take about 60 days.
The Code
This is the code I'm using at each "chunk" loop. The code is modified to remove some cancellation token and progress report calls. I also added a comment to highlight the call that takes 400+ms.
for (int i = 0; i < rowCount; i++)
for (int j = 0; j < colCount; j++)
int row = i, col = j; //this is done because task start could have a modified value on call
Rect rect = new Rect(
col * maxWidth,
row * maxHeight,
col + 1 < colCount ? maxWidth :
surfaceWidth - (colCount - 1) * maxWidth,
row + 1 < rowCount ? maxHeight :
surfaceHeight - (rowCount - 1) * maxHeight);
DrawingVisual visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
VisualBrush brush = new VisualBrush(element)
Viewbox = rect,
ViewboxUnits = BrushMappingMode.Absolute,
Stretch = Stretch.None
;
dc.DrawRectangle(brush,
null,
new Rect(0, 0, rect.Width, rect.Height));
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)(rect.Width * (imgdpi / DEFAULT_DPI)),
(int)(rect.Height * (imgdpi / DEFAULT_DPI)),
imgdpi,
imgdpi,
PixelFormat);
//***********************//
//THIS IS THE CALL THAT TAKES 400+ms
//***********************//
bitmap.Render(visual);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
//... Some additional code to work with the chunk asynchronously
Things I've tried
I've tried several things:
- Calling Dispatcher.DisableProcessing: I was thinking that it could have been that the UI kept trying to update the surface while processing the chunks (althought my understanding that if it has not been modified it shouldn't be much of a problem). But this did not change the processing time.
- While creating the VisualBrush object to assign to it smaller Viewports (chunk size or bigger). The time actually increased.
- Adding CacheMode to the Canvas: The time actually increased and the image looked low resolution.
- Some additional desperate measures that made no sense haha.
Additional Information
Since I'm not completely sure how this Render functionality works internally (And I have searched for information on these, but what I've found is superficial at best) I'm not sure if the cause is the large surface or the number of controls in the surface (or a combination of both). So here is some additional information on the test case that is taking 400ms per render:
- Surface Size is: 74052.75px x 1119.4px.
- N. of Graph's Nodes: 1977.
- N. of Connectors (Arrows): 2052.
- Each Control visual is defined in the XAML using resources.
- Each Graph Node is a Filled Rectangle with a Textblock at its center.
- Each Connector is a straight line with a triangle at one of its edges.
Also, since the very large image generation is not something that will happen that often, and not to a regular user. I would not mind if the solution provided sacrifices UI responsiveness.
Notes added to clarify some concerns in the comments section
- The graph is shown on screen to the user, this can be manipulated by it.
- The "Store as Image" functionality is just an additional optional functionality to save the graph as an Image file. (This works under normal load, the speed issue happens with an unnusually large graph).
I'd appreciate any help you could provide.
Thanks!
c# wpf
c# wpf
edited May 2 at 23:27
MrZeruel
asked Mar 27 at 17:15
MrZeruelMrZeruel
235 bronze badges
235 bronze badges
1
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49
|
show 8 more comments
1
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49
1
1
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49
|
show 8 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383028%2frendering-part-of-large-visual-object-performance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55383028%2frendering-part-of-large-visual-object-performance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Have you tried multithreading? Also, if you're working with image processing and performance is critical, maybe it's time to reconsider whether WPF is really what you should be using.
– Abion47
Mar 27 at 17:21
There is also a solution like this one where instead of re-rendering the visuals, you use Win32 commands to capture those pixels on the screen. The problem with that approach, of course, is that the entire image you are trying to capture needs to be visible on the screen, which seems unlikely given the image resolutions you say you are working with.
– Abion47
Mar 27 at 17:27
@Abion47 I have tried Multithreading, the problem is that the DrawingVisual, brush, RenderTargetBitmap and Bitmap Encoder needs to work at the Dispatcher's thread. I'm actually using multithreading after this part is done to work in parallel what I can. And I have to stick with WPF because of the library I'm using.
– MrZeruel
Mar 27 at 17:38
@Abion47 About the other solution, I'll give it a go, scrolling through the surface might be possible, I'll have a look at it. Thanks
– MrZeruel
Mar 27 at 17:38
@Abion47 You do realise WPF is hardware-accelerated when used properly? You can write your own shaders too
– MickyD
Mar 30 at 0:49