CreateCompatibleBitmap CreateBitmap 区别

来源:互联网 发布:龙将新一路相随数据 编辑:程序博客网 时间:2024/06/08 17:35

After a bitmap is created, it can be selected into a device context by calling theSelectObject function.

While the CreateBitmap function can be used to create color bitmaps, for performance reasons applications should useCreateBitmap to create monochrome bitmaps and CreateCompatibleBitmap to create color bitmaps. When a color bitmap returned fromCreateBitmap is selected into a device context, the system must ensure that the bitmap matches the format of the device context it is being selected into. BecauseCreateCompatibleBitmap takes a device context, it returns a bitmap that has the same format as the specified device context. Because of this, subsequent calls toSelectObject are faster than with a color bitmap returned from CreateBitmap.

If the bitmap is monochrome, zeros represent the foreground color and ones represent the background color for the destination device context.

If an application sets the nWidth or nHeight parameters to zero,CreateBitmap returns the handle to a 1- by 1-pixel, monochrome bitmap.

When you no longer need the bitmap, call the DeleteObject function to delete it. 

0 0