GDI+ 创建图像

    技术2022-05-11  68

    从内存中创建图像     创建一个空的图像可以利用其构造函数来完成

    [C#]

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

    [VB]

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

    这种方法是利用缺省的颜色深度参数;于指定的颜色深度参数,可以在构造函数指定像素参数.

    [C#]

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

    [VB]

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

    创建位图图像时有效的像素参数是:

    Format16bppArgb1555

    Format16bppGrayScale

    Format16bppRgb555

    Format16bppRgb565

    Format1bppIndexed

    Format24bppRgb

    Format32bppArgb

    Format32bppPArgb

    Format32bppRgb

    Format48bppRgb

    Format4bppIndexed

    Format64bppArgb

    Format64bppPArgb

    Format8bppIndexed

     

    当图像创建时,图像内存被清为0,这就表示,图像显示为黑色的.当图像有alpha通道时是完成透明的,

     

    2.图像可以从磁盘上的任何标准的图像格式(JPEG, GIF, TIFF 或者Windows 位图)文件创建。

     

    下面演示了利用Image的静态或共享方法:Image.FormFile

     

    [C#]

     

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

     

    [VB]

     

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

     

    最新回复(0)