Department of InformatiX
Microsoft .NET Micro Framework Tools & Resources
Core (2)
Globalization
Peripherals
WPF (1)
Networking (4)
Developing
Emulators (2)
Port specifics
Others

Bitmaps & Rendering

How can I create new Bitmap with specified bit depth?

The only way is to use the constructor taking a byte array and supplying a bitmap data with the desired format. You can for example create black bitmap in your favorite imaging software and include it as a binary resource in the project. If you don't know the bitmap's dimensions at design time, the only option is to generate the bitmap byte array on the fly. The bitmap headers included in FusionWare.SPOT library on CodePlex could help you with that.

How can I get to the bitmap's data array? GetColor(x, y) is too slow...

Steve MailletUnfortunately, there is no way to get the raw pixel data for manipulation.

Is there any way how to wait until the Invalidate method finishes repainting?

Well the Invalidate internally uses BeginInvoke method and the dispatcher repaints the control as soon as possible. If you have a thread which stresses the device so much that "as soon as possible" never occurs, you will not see your control repainted, although the emulator on your fast computer may not indicate so. One workaround might be to use reflection to access the _flags non-public field of the UIElement and test it for the IsSubtreeDirtyForRender value:
public static bool IsRepainted(/* this */ UIElement element) { FieldInfo flags = typeof(UIElement).GetField("_flags", BindingFlags.Instance | BindingFlags.NonPublic); uint value = (uint)flags.GetValue(element); // Flags.IsDirtyForRender | Flags.IsSubtreeDirtyForRender return (value & 6) == 0; }

You may also want to try the DoEvents WPF equivalent, as described in this article.