GDI - How to create and fill bitmap?

允我心安 提交于 2019-12-13 07:15:11

问题


Someone can give me short explanation how to create bitmap runtime using GDI/GDI+ and to fill it with color ?

Thanks in advance.


回答1:


  1. CreateBitmap, CreateCompatibleBitmap or CreateDIBSection (in case you want access to raw underlying data bits)
  2. CreateCompatibleDC
  3. SelectObject the bitmap into created device context
  4. FillRect 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 do SetBkColor + ExtTextOut with an empty string and ETO_OPAQUE and the rectangle will be filled)
  5. SelectObject back
  6. The bitmap remains to hold the painting
  7. Release the resources

Still it has something to do with "entire screen" in the title, and you need explain what you want there.




回答2:


  1. Query screen size

  2. Create your drawable (or just manipulate the graphics object in your paint handler)

  3. Fill it with color

:)



来源:https://stackoverflow.com/questions/11037228/gdi-how-to-create-and-fill-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!