Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphic Device Interface

Similar presentations


Presentation on theme: "Graphic Device Interface"— Presentation transcript:

1 Graphic Device Interface
GDI/GDI+ Graphic Device Interface

2 What it is? It enables applications to use graphics
It do not access the graphics hardware directly interacts with device drivers More or less obsolete (Direct2D)

3 Before we go... WM_PAINT! is sent when the system or another application makes a request to paint a portion of an application's window UpdateWindow RedrawWindow InvalidateRect

4 Device Context is a structure that defines a set of graphic objects and their associated attributes, as well as the graphic modes that affect output Device independence - applications can draw and print output on a variety of devices Gdi.dll Device driver

5 DC functions BeginPaint GetDC GetCompatibleDC
GetCurrentObject -> GetObject GetStockObject SelectObject Etc...

6 Principles When you want to draw a line, you are using Pen
When you want to color something, you are using Brush It is possible to use multiple pens and brushes, but only one at a time SelectObject

7 Pen LineTo Polyline TextOut Etc... PS_SOLID PS_DASH PS_DOT PS_DASHDOT
HPEN CreatePen( _In_ int fnPenStyle, _In_ int nWidth, _In_ COLORREF crColor); PS_SOLID PS_DASH PS_DOT PS_DASHDOT PS_DASHDOTDOT PS_NULL PS_INSIDEFRAME LineTo Polyline TextOut Etc...

8 Brush CreateHatchBrush CreatePatternBrush Etc… Ellipse Polygon
HBRUSH CreateSolidBrush( _In_ COLORREF crColor ); CreateHatchBrush CreatePatternBrush Etc… Ellipse Polygon Rectangle Etc...

9 Bitmaps Device context is needed Capturing or displaying bitmap
CreateCompatibleDC Capturing or displaying bitmap CreateCompatibleBitmap BitBlt StretchBlt

10 Clipping is the process of limiting output to a region or path within the client area of an application window A clipping region is a region with edges that are either straight lines or curves A clip path is a region with edges that are straight lines, Bézier curves, or combinations of both

11 Using Clipping (I) Create clip path BeginPath/EndPath RGN_AND RGN_COPY
RGN_DIFF RGN_OR RGN_XOR BOOL SelectClipPath( _In_ HDC hdc, _In_ int iMode);

12 Using Clipping (II) Functions NULLREGION SIMPLEREGION COMPLEXREGION
int SelectClipRgn( _In_ HDC hdc, _In_ HRGN hrgn ); Functions CombineRgn CreatePolygonRgn CreateRectRgn Etc… NULLREGION SIMPLEREGION COMPLEXREGION ERROR

13 Coordinate Spaces and Transformations
Drawing with predefined units Centering Scaling Translating Rotating Shearing Reflecting SetGraphicsMode SetMapMode SetWorldTransform XFORM

14

15 Other possibilities Fonts and texts Metafiles
Multiple display monitors

16 Clear your mess Keep and restore old values Release drawing handles
Select Object DeleteObject Release drawing handles EndPaint ReleaseDC


Download ppt "Graphic Device Interface"

Similar presentations


Ads by Google