.
GDI+ FAQ
Skip Navigation LinksWelcome : GDI+ FAQ : Creating and loading images

Creating a new blank image is accomplished with the Bitmap constructor.

[C#]

Bitmap myImage = new Bitmap(<xsize>,<ysize>);

[VB]

Dim MyImage = new Bitmap(<xsize>,<ysize>)

This method creates an image with the default color depth parameters. To specify a color depth, you can also specify a pixel format parameter in the constructor.

[C#]

Bitmap myImage = new Bitmap(<xsize>,<ysize>,PixelFormat.<format>);

[VB]

Dim MyImage = new Bitmap(<xsize>,<ysize>,PixelFormat.<format>)

The Pixel Formats valid for the creation of a bitmap image are:

Format16bppArgb1555

Format16bppGrayScale

Format16bppRgb555

Format16bppRgb565

Format1bppIndexed

Format24bppRgb

Format32bppArgb

Format32bppPArgb

Format32bppRgb

Format48bppRgb

Format4bppIndexed

Format64bppArgb

Format64bppPArgb

Format8bppIndexed

 

When created, the images memory area is cleared to 0. This means that images may appear black and be completely transparent if the image is one capable of storing per-pixel alpha values.


Images may be loaded from disc in any of the standard formats (JPEG, GIF, TIFF or Windows Bitmap)

 

This is performed with the Image static or shared method Image.FromFile

 

[C#]

 

Bitmap bm = (Bitmap)Image.FromFile("<filename>");

 

[VB]

 

Dim bm as Bitmap = CType(Image.FromFile("<filename">),Bitmap)

 


 

Sponsored By
DaraizeTechnologies.com

&
Proteus Groupe

Bob Powell

Create your badge

Copyright © Bob Powell 2000-2012.  All rights reserved.