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 can specify the position of the draw destination on the display as well as the top left and bottom right corners of the region to be extracted from the source bitmap. This would allow you to have a single bitmap resource that contains a range of different icons and then place different items from the source bitmap into a particular position in the destination one.

image from book
Figure 7-8: Drawing a full-size snowflake image.

Note 

This form of drawing does not perform any scaling on the source bitmap. If you wish to scale images, you must use the StretchImage method described in the next section.




Embedded Programming with the Microsoft .Net Micro Framework
Embedded Programming with the Microsoft .NET Micro Framework
ISBN: 0735623651
EAN: 2147483647
Year: 2007
Pages: 118

Similar book on Amazon
Getting Started with the Internet of Things: Connecting Sensors and Microcontrollers to the Cloud (Make: Projects)
Getting Started with the Internet of Things: Connecting Sensors and Microcontrollers to the Cloud (Make: Projects)
Expert .NET Micro Framework (Expert's Voice in .NET)
Expert .NET Micro Framework (Expert's Voice in .NET)
Netduino Plus
Netduino Plus
Getting Started with Netduino
Getting Started with Netduino

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net