VisaToHell
VisaToHell

Reputation: 508

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 ?

Thanks in advance.

Upvotes: 1

Views: 3096

Answers (2)

Roman Ryltsov
Roman Ryltsov

Reputation: 69662

  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.

Upvotes: 7

paulsm4
paulsm4

Reputation: 121649

  1. Query screen size

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

  3. Fill it with color

:)

Upvotes: 0

Related Questions