简体   繁体   English

GDI-如何创建和填充位图?

[英]GDI - How to create and fill bitmap?

Someone can give me short explanation how to create bitmap runtime using GDI/GDI+ and to fill it with color ? 有人可以给我简短的解释,如何使用GDI / GDI +创建位图运行时并用颜色填充它?

Thanks in advance. 提前致谢。

  1. CreateBitmap , CreateCompatibleBitmap or CreateDIBSection (in case you want access to raw underlying data bits) CreateBitmapCreateCompatibleBitmapCreateDIBSection (如果要访问原始基础数据位)
  2. CreateCompatibleDC
  3. SelectObject the bitmap into created device context 将位图SelectObject放入创建的设备上下文中
  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) FillRect或设备上下文上的朋友,绘制将在您选择的位图上进行(有选项:黑色和白色的标准画笔,手上有RGB而不是创建画笔,您可以使用空字符串执行SetBkColor + ExtTextOutETO_OPAQUE和矩形将被填充)
  5. SelectObject back SelectObject返回
  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. 仍然与标题中的“整个屏幕”有关,您需要在其中解释您想要的内容。

  1. Query screen size 查询画面尺寸

  2. Create your drawable (or just manipulate the graphics object in your paint handler) 创建您的可绘制对象(或仅在绘制处理程序中操作图形对象)

  3. Fill it with color 用颜色填充

:) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM