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 Scaling

The StretchImage method also draws one bitmap on top of another, but instead of allowing a rectangle of the source bitmap to be selected for the draw operation, the entire source rectangle is stretched or shrunk to fit a destination rectangle.

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

myBitmap.StretchImage(
    10, 10,                                // destination x, y
    snowflake,                             // source bitmap
    200, 100,                              // width and height of destination
    0xff);                                 // opacity

myBitmap.Flush();

Irrespective of the size of the original, the snowflake will be drawn in a rectangle 200 pixels wide and 100 pixels high (Figure 7-9). The snowflake image doubled in width during the draw process.

Figure 7-9. The snowflake image stretched into a 200-pixel by ...

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