问题
Someone can give me short explanation how to create bitmap runtime using GDI/GDI+ and to fill it with color ?
Thanks in advance.
回答1:
CreateBitmap
,CreateCompatibleBitmap
orCreateDIBSection
(in case you want access to raw underlying data bits)CreateCompatibleDC
SelectObject
the bitmap into created device contextFillRect
or friends on the device context, and the painting takes place on your selected bitmap (there are options there: standard brushes for black and white, having RGB on hands instead of creating a brush you can doSetBkColor
+ExtTextOut
with an empty string andETO_OPAQUE
and the rectangle will be filled)SelectObject
back- The bitmap remains to hold the painting
- Release the resources
Still it has something to do with "entire screen" in the title, and you need explain what you want there.
回答2:
Query screen size
Create your drawable (or just manipulate the graphics object in your paint handler)
Fill it with color
:)
来源:https://stackoverflow.com/questions/11037228/gdi-how-to-create-and-fill-bitmap