Microsoft SDK for Java

Drawing Bitmaps

A bitmap is a drawable surface. This surface can be used to display pens, brushes, or images, including Windows bitmaps, metafiles, .gif, and .jpg images.

The Bitmap object supports creating and loading bitmaps. You can use this object to load bitmap images from files, streams, or resources, or you can use it to create bitmaps in memory. In addition, the Bitmap object supports defining transparent colors within a bitmap.

After creating a Bitmap object, you use the Graphics object's drawImage method to render a Bitmap object to the display.

The following code fragment creates a new Bitmap object, and then uses the Form class's createGraphics method to create the Graphics object for drawing the image.

Example

Bitmap bmp = new Bitmap("c:\\MyImage.bmp");
Graphics g = this.createGraphics();

g.drawImage(bmp, new Point(10, 10));

For more information, see:

Shrinking and Expanding Images

Rendering Images Transparently

© 1999 Microsoft Corporation. All rights reserved. Terms of use.