Search code examples
c#graphicscompact-frameworkraster

Fast display of raw pixel data from byte[] .net Compact Framework


I'm playing with rasters and I want to know the fastest way to paint a byte[] to the screen using the .net CF. The array is a standard 24bit raster (Screen.Width * Screen.Height * 3 in length, RGB order) and right now I'm saving the array to a Bitmap object and drawing it to the screen using the Graphics.DrawImage(bmp) method. I feel that there must be someway of doing this w/o having to create a Bitmap.

I'm using C#, but I can to go native if needs be (I'd prefer P/Invokes if possible, assuming that is the case)

Thanks for any help!


Solution

  • When drawing images, I found the native BitBlt to perform alot better than using .NET Graphics, you could use it to display your Bitmap or even use GDI to create the bitmap instead.

    http://msdn.microsoft.com/en-us/library/aa923590.aspx

    An example of using BitBlt in .NET CF (although it's the reverse of what you are doing, and in VB.NET):

    http://anoriginalidea.wordpress.com/2008/01/03/getting-a-screenshot-using-vbnet-on-the-compact-framework-20/