Priting a full screen on text, character by character

J

jonny

Everyone,

I am having a problem with perfromance and the drawing of strings on a
panel control and I am hoping you all can help or at least provide me
with some good reference material. Here is what I am doing:

I am using C# 2003 and reading into a file in real-time and as I scroll
a scrollbar control, I am grabbing the bytes, converting them to chars,
calculating the number of visible lines and creating an array of strings
(not in the pain event) and then displaying them on a panel control by
overriding the on-paint method on the panel control and looping the
array of strings then drawing them to the panel. This has proved to be
extremely fast and efficient even with 700MB files and having the
control at full-screen size. My problem is that I want to allow the
multiple coloring of characters and be able to retain the speed that I
have. If I remove the line calculation portion of my code and render the
entire panel character-by-character in the onPaint event, I find that
there is much lag when trying to draw the characters one by one and
apply a color style.

Does anybody have any ideas on how I can render say, 7000 individual
characters on a control and be able to scroll it (7000 new characters
each time) without any lag by using either .NET's GDI+ or mabye even
just GDI? I am currently using DrawString and the OnPaint event and have
even tried drawing to a memory bitmap and just having the OnPaint event
render the bitmap when scrolling. The only problem with the latter
method is that rendering an image of 1024x768 a few hundred times in a
second or so is even slower than drawing the character one at a time.

Any help here?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Well, a simplest optimization would be to split the text into chunks having
the same color and draw the text chunk-by-chunk instead of
character-by-character.
It also sounds a bit strange using the off-screen bitmap is that slow.
Ensure you don't use the stretch mode and that the bitmap has the same pixel
format the screen has.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top