130 likes | 380 Views
GDI+ getting started. GDI+. Class-based API for C/C++ Windows Graphics Device Interface (GDI) Device-independent applications Services 2D vector graphics Drawing primitives Imaging Bitmap Typography Display of text. Setup. Header file #include <gdiplus.h> Linking library
E N D
GDI+ • Class-based API for C/C++ • Windows Graphics Device Interface (GDI) • Device-independent applications • Services • 2D vector graphics • Drawing primitives • Imaging • Bitmap • Typography • Display of text
Setup • Header file • #include <gdiplus.h> • Linking library • #pragma comment (lib, “gdiplus.lib”) • Namespace • using namespace Gdiplus; • Initialization GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup (&gdiplusToken, &gdiplusStartupInput, NULL);
Pen Graphics graphics (hdc); • DrawLine Pen pen (Color (255, 255, 0, 0)); graphics.DrawLine (&pen, 20, 10, 300, 100); • DrawRectangle Pen blackPen (Color (255, 0, 0, 255), 5); graphics.DrawRectangle (&blackPen, 10, 100, 100, 50);
Pen • DrawPath GraphicsPath path; Pen penJoin (Color (255, 0, 255, 0), 25); path.StartFigure (); path.AddLine (Point (100, 200), Point (200, 200)); path.AddLine (Point (200, 200), Point (200, 300)); graphics.DrawPath (&penJoin, &path);
Brush Graphics graphics (hdc); SolidBrush solidBrush (Color (255, 255, 0, 0)); graphics.FillEllipse (&solidBrush, 10, 10, 100, 60); Image image (L"Glass.bmp"); TextureBrush tBrush (&image); tBrush.SetTransform (&Matrix (75.0/128.0, 0.0f, 0.0f, 75.0/128.0, 0.0f, 0.0f)); graphics.FillRectangle (&tBrush, 0, 150, 150, 250);
String Graphics graphics (hdc); SolidBrush brush (Color (255, 0, 0, 255)); FontFamily family (L“Arial"); Font font (&family, 24, FontStyleRegular, UnitPixel); PointF pointF (10.0f, 20.0f); graphics.DrawString (L"Hello World!", -1, &font, pointF, &brush);
Introduction • Based on • Win32 API • DirectShow API • GDI+ API • IDE • Visual C++ 2005 Express • Platform SDK • LNK1104: cannot open file 'atlthunk.lib' (www.codeproject.com/wtl/WTLExpress.asp)
DirectShow • Capture and playback of multimedia streams for a variety of formats • A media-streaming architecture • You can download Platform SDK or previous DirectX SDK from our course webpage
Setup • Header file • #include <Dshow.h> • Linking library • #pragma comment (lib, “Strmiids.lib”) • Set the path in your IDE • Platform SDK • DirectX SDK
Your Job • In HRESULT ProcessBuffer (HDC hDC) • Write a simple image processing program to scan pBuffer. • The information (size, RGB, ..) of pBuffer is stored in pInfo->bmiHeader.