Re: Speed of C# and GDI+

From: Kartal (keturkarslan_at_hotmail.com)
Date: 05/07/04


Date: 7 May 2004 03:43:34 -0700

Hi Mateusz,

.NET CF compiler generates MSIL code which is a CPU independent
intermediate code. .NET CF converts MSIL code to appropriate machine
code when managed method executed for the first time. However this
conversion does not cause a very big performance issue for most of the
applications. At the end you are actually running the machine code,
.NET CF is not an interpreter. However .NET CF is a framework between
the operating system and your application. I can neglect the overhead
of that the framework layer but it may not be acceptable for your
applcation.

I would suggest you to develop two small test applications and measure
the performance between.

I prefer .NET CF as it abstracts the hardware differences and
eliminates problems such as byte alignment etc. So you do not need to
test on different platforms and single code runs PPC 2003 and PPC
2002. Designing the UI and implementing the application is also very
simple.

If it is acceptable to draw the screen after completing all the
processing and drawing, there is also third option.
  You can do all you geometry processing in an eVC++ dll.
  Within that DLL you can paint everything to a memory DC.

  .NET CF classes does not expose a bitmap handle or window handle
which you can use from the unmanaged (eVC++) code. However the Bitmap
class provides a constructor which takes a stream parameter.

   You can call your eVC++ dll and query the size of the bitmap as if
it was going to written to a file. With the returned value you can
create a byte array in your .NET CF code and call unmanaged dll again
with this array as the parameter.

   In your eVC++ code you can fill this array with your result bitmap
which you can extract from memory DC. You can refer to codes on how to
write a bitmap to a file. The array should contain the same info in
the same order.

   When your function returns with the filled array you can create a
memory stream out of it and use that stream as a parameter to bitmap
constructor.

This technique will work faster than you first scenario and eliminates
your performance concerns as the processing and drawing will be done
on the unmanaged code.

Ercan

keturkarslan at hotmail dot com



Relevant Pages

  • Re: Speed of C# and GDI+
    ... .NET CF compiler generates MSIL code which is a CPU independent ... However the Bitmap ... class provides a constructor which takes a stream parameter. ... with this array as the parameter. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: overlay text on uploaded picture
    ... If it is then all I need to do is stream my original image ... The reason I was creating a second bitmap is that I need the image in the ... form of a Byte array. ... I couldn't go direct from a Graphics object to a Byte array so I ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: System.Drawing.Image and jpg images
    ... > then like to read the data and reconstruct the jpg. ... > into a byte array, and this is where I'm stumped. ... I assume it's expecting a bitmap. ... > stream the bytes to a disk file and then read it back in, ...
    (microsoft.public.dotnet.framework)
  • Re: Pset and SetPixel Bug
    ... The method varies slightly depending on what kind of bitmap you are dealing with and also where you are getting it from. ... Once you know the address you can then point a SAFEARRAY structure at that data and access it from the array. ... Private Declare Function timeBeginPeriod _ ... Dim SourceWidth As Long, SourceHeight As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Pset and SetPixel Bug
    ... The method varies slightly depending on what kind of bitmap you are dealing with and also where you are getting it from. ... Once you know the address you can then point a SAFEARRAY structure at that data and access it from the array. ... Private Declare Function timeBeginPeriod _ ... Dim SourceWidth As Long, SourceHeight As Long ...
    (microsoft.public.vb.general.discussion)