11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8. DC, Pen, Brush and Palette<br />

The device supports 256 colors<br />

There are 20 static colors<br />

Color resolution is 18 bits<br />

Horizontal size is 270 mm, 1024 pixels<br />

Vertical size is 203 mm, 768 pixels<br />

Summary:<br />

1) Before drawing anything to a window, we must first obtain its device context. There are many ways of<br />

obtaining a window’s DC (Calling function CWnd::GetDC(), declaring CClientDC or CWindowDC type<br />

variables, etc.).<br />

1) A client DC can be used to paint a window’s client area, and a window DC can be used to paint the<br />

whole window (client and non-client area).<br />

1) Pen can be used to draw line, the border of rectangle, polygon, ellipse, etc. A pen can have different<br />

styles: solid pen, dotted pen, dashed pen, etc.<br />

1) Brush can be used to fill the interior of rectangle, polygon, ellipse, etc. A brush can have different<br />

patterns: solid, hatched, etc.<br />

1) We can use an 8×8 image to create pattern brush.<br />

1) On a palette device, there are two color approaching methods: dithering and using the nearest color.<br />

1) Logical palette can be used to avoid color distortion. To use a logical palette, we need to create it,<br />

select it into DC, and realize the palette.<br />

1) System palette can be monitored by creating a logical palette whose entries are set to PC_EXPLICIT<br />

flags.<br />

1) Palette animation can be implemented by creating a logical palette whose entries are set to<br />

PC_RESERVED flag.<br />

1) The abilities of a device can be retrieved by calling function CDC::GetDeviceCaps().<br />

235

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!