Drawing speed and GetHdc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm using VS.NET 2003 and C# to build a little CAD application for Compact Framework. I've seen that the drawing speed is quite low (in the emulator...), I've used DrawLine method. How can I increase the drawing performance ?

To solve this problem I've tried to use DllImport attribute and tried to use the old MoveTo and LineTo, but in the Graphics object I cannot call the GetHdc method. Is this method available for Compact Framework or not ? If not what can I do ?

Thank you in advance for your help.

Keven Corazza
 
Emulator performance is low, especially in drawing operations. Test on a
real device to see if you need improvements,
The Graphics object methods mostly translate directly into Native OS calls
with very little overhead.
Method, that returns HDC is not supported on CF

Keven Corazza said:
Hi, I'm using VS.NET 2003 and C# to build a little CAD application for
Compact Framework. I've seen that the drawing speed is quite low (in the
emulator...), I've used DrawLine method. How can I increase the drawing
performance ?
To solve this problem I've tried to use DllImport attribute and tried to
use the old MoveTo and LineTo, but in the Graphics object I cannot call the
GetHdc method. Is this method available for Compact Framework or not ? If
not what can I do ?
 
Emulator performance is low, especially in drawing operations. Test on a
real device to see if you need improvements,
The Graphics object methods mostly translate directly into Native OS calls
with very little overhead.

yes - true, the Emulator is damn slow.

But: setting pixels is extremly slow on a real device too!
and drawing many lines is very slow too (try to draw some gradients with
short lines and see what i mean - FAR away from "realtime")

Boris
 
Hi Boris,

Try drawing to an off screen bitmap and then drawing the bitmap to the
screen all at once. This will usually improve preformance. You may also
want to check out the FAQ:

2.2. What can I do to optimize GDI+ rendering?
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#2.2

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
I've tried to draw on a offscreen image but the performance are the same. Is this normal ?
 
Thank you Alex, for your answer. I've tested your example (RubberBand) and I've seen how to get the DC from a windows. Now I have two questions:

1. To draw on my windows I can use Polyline function but if I try to use MoveTo and LineTo functions I get an error "MissingMethodException". Why I can use Polyline and not MoveTo and LineTo ?

2. I'm trying now, to increase the performance, to draw on a off-screen image. I've tried it with CF class but the speed is the same, I don't understand why. Anyway, to use Polyline I need to get the DC of an image. How can I do that ?

Thank you in advance.

Keven Corazza
 
Keven Corazza said:
Thank you Alex, for your answer. I've tested your example (RubberBand) and
I've seen how to get the DC from a windows. Now I have two questions:
1. To draw on my windows I can use Polyline function but if I try to use
MoveTo and LineTo functions I get an error "MissingMethodException". Why I
can use Polyline and not MoveTo and LineTo ?

Because MoveTo and LineTo do not exist in Windows CE. You can easily replace
them with Polyline
2. I'm trying now, to increase the performance, to draw on a off-screen
image. I've tried it with CF class but the speed is the same, I don't
understand why. Anyway, to use Polyline I need to get the DC of an image.
How can I do that ?

Unfortunately, the way it is right now, you will need to perform all
offscreen drawing using unmanaged approach. Mix and match won't work.
Use CreateCompatibleDC and CreateCompatibleBitmap to create offscreen canvas
 
Try drawing to an off screen bitmap and then drawing the bitmap to the
screen all at once. This will usually improve preformance. You may also
want to check out the FAQ:

i do this allready! But it's too slow...

for example:
- i have build a form to let a user sign on it (after some days of testing
and finishing i've found the example from MS :( .. to late ;) )

the speed is OK using MouseDown,-Move,-Up and then draw lines.

Then i like to put a bitmap in the background - now things were going slow.
You still are able to sign - but when you draw a circle it's not a circle,
it's thing with 7 to 9

it may be possible to speed it up but just painting an area around the pen
- not the whole screen... i will see... until then i don't use the
background-bitmap

BTW: i've read the sign-sample from MS (just looked at the web-site) and i
think the sign is slow too! you can see, that the sign in the screen-shot
is not very detailed!

i know ;)

Boris
 
Hi Keven,

It really depends, there are many situations where this will help
performance but not always. It also tends to help issues with screen
flicker.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
Keven Corazza said:
I've tried to draw on a offscreen image but the performance are the same.
Is this normal ?
 
Back
Top