O'Reilly logo

Embedded Programming with the Microsoft® .NET Micro Framework by Rob Miles, Donald Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Image Drawing

The Bitmap class provides a method called DrawImage that allows one bitmap to draw part or all of another bitmap on itself.

Bitmap snowflake = Resources.GetBitmap(Resources.BitmapResources.MFsnowflake);

myBitmap.DrawImage(
    10, 10,                                    // destination x, y
    snowflake,                                 // source bitmap
    0, 0,                                      // x, y in source
    snowflake.Width, snowflake.Height          // source width, height
    0xff);                                     // opacity

myBitmap.Flush();

This code gets a bitmap from a resource and then uses DrawImage to render the bitmap. The entire bitmap is drawn 10 pixels down and 10 pixels from the left edge of the origin. The Width and Height properties of the source bitmap are used to ensure that the entire bitmap is drawn.

Figure 7-8 shows the full-size display of the snowflake image. You ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required