Author Topic: 16. Graphics Review  (Read 927 times)

0 Members and 1 Guest are viewing this topic.

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5934
  • 'All I like is finishing'
16. Graphics Review
« on: September 05, 2011, 09:22:53 PM »
The core OS component responsible for representing graphical objects and transmitting them to output devices such as monitors and printers is the Graphics Device Interface (GDI).  GDI is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. It is not directly responsible for drawing windows, menus, etc..  Those tasks are performed by the user subsystem, which resides on top of the GDI. The components which connect the GDI to the various devices that can be drawn to are called device drivers.

The OS informs GDI to prepare the device for drawing operations (such as selecting a line color and width, a brush pattern and color, a font typeface, a clipping region, and so on). These tasks are accomplished by creating and maintaining a device context (DC). A DC is a structure that defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. The graphic objects include a pen for line drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a palette for defining the set of available colors, a region for clipping and other operations, and a path for painting and drawing operations (see chart below). The actual context is maintained by GDI. A handle to the DC (HDC) is obtained before output is written and then released after elements have been written.
A DC, like most GDI objects, is opaque - its data cannot be accessed directly, but its handle can be passed to various GDI functions that will operate on it, either to draw an object, to retrieve information about it, or to change the object in some way.
When an application creates a DC, the system automatically stores a set of default objects in it. (There is no default bitmap or path.) The application can change these defaults by creating a new object and selecting it into the DC.

Graphic objects and Associated attributes
Bitmap - Size, in bytes; dimensions, in pixels; color-format; compression scheme; and so on.
Brush - Style, color, pattern, and origin.
Palette - Colors and size (or number of colors).
Font - Typeface name, width, height, weight, character set, and so on.
Path - Shape.
Pen - Style, width, and color.
Region - Location and dimensions.

With the introduction of Windows XP, GDI was deprecated in favor of its successor, the GDI+ subsystem.  GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline. GDI+ uses ARGB values to represent color.


Coming Next - WM_PAINT Setup
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library