Windows Graphics Device Interface Plus GDI gdiplus'dll - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Windows Graphics Device Interface Plus GDI gdiplus'dll

Description:

the Pen class stores information about line color, width, and style ... It's the class that actually draws lines, curves, figures, images, and text ... – PowerPoint PPT presentation

Number of Views:379
Avg rating:3.0/5.0
Slides: 13
Provided by: patpa
Category:

less

Transcript and Presenter's Notes

Title: Windows Graphics Device Interface Plus GDI gdiplus'dll


1
Windows Graphics Device Interface
PlusGDIgdiplus.dll
2
Microsoft Windows GDI
  • Graphics Device Interface
  • two-dimensional vector graphics
  • Imaging
  • Typography
  • GDI is on Windows XP and Windows Server 2003
  • GDI improves on Windows Graphics Device
    Interface (GDI)
  • GDI was included with earlier versions of Windows
  • backwards compatibility with (plain old) GDI is
    present
  • GDI adds new features and speeds up existing
    features

3
overview of GDI
  • .NET class libraries
  • System.Drawing
  • System.Drawing.Drawing2D
  • GDI allows application programmers to display
    information on a screen or printer without
    knowing about a particular display device
  • the programmer calls methods provided by GDI
    classes and those methods in turn make the
    appropriate calls to specific device drivers
  • GDI insulates the application from the graphics
    hardware
  • this insulation that allows developers to create
    device-independent applications

4
3 parts to GDI
  • Windows GDI offers three broad capabilities
  • 2-D vector graphics
  • imaging
  • typography

5
2-D vector graphics
  • Vector graphics
  • drawing lines, curves, and figures that are
    specified by sets of points on a coordinate
    system
  • a straight line can be specified by its two
    endpoints
  • a rectangle can be specified by a point giving
    the location of its upper-left corner and a pair
    of numbers giving its width and height
  • a path can be specified by an array of points to
    be connected by straight lines
  • a Bezier spline is a sophisticated curve
    specified by four control points
  • GDI provides
  • classes that store information about location
  • the Rectangle class stores the location and size
    of a rectangle
  • the Point class stores a pixel location on the
    screen
  • classes that store information about how to draw
  • the Pen class stores information about line
    color, width, and style
  • several Brush classes store information about how
    closed figures are to be filled with colors or
    patterns
  • a class that actually does the drawing
  • the Graphics class has methods for drawing lines,
    rectangles, paths, and other figures

6
imaging
  • some pictures are difficult or impossible to
    display with the techniques of vector graphics.
  • i.e., pictures on buttons or icons would be
    difficult to specify as collections of lines and
    curves
  • a photograph of a crowd would be even more
    difficult to create with vector graphics
  • images of this type are stored as bitmaps
  • a bitmap is an array of numbers that represent
    the colors of individual dots on the screen
  • data structures for bitmaps are more complex than
    those required for vector graphics
  • there are several classes in GDI devoted to this
    purpose
  • i.e., CachedBitmap stores a bitmap in memory for
    fast access and display

7
typography
  • the display of text in a variety of fonts, sizes,
    and styles
  • GDI provides a lot of support for this complex
    task
  • one of the new features in GDI is subpixel
    antialiasing
  • gives text rendered on an LCD screen a smoother
    appearance

8
the GDI class interface
  • about 40 classes, 50 enumerations, and 6
    structures
  • the Graphics class is the core of the GDI
    interface
  • Its the class that actually draws lines, curves,
    figures, images, and text
  • containers such as forms and panels pass these to
    their OnPaint() methods
  • other classes work together with the Graphics
    class
  • the GraphicsDrawLine method
  • requires a Pen object
  • holds attributes (color, width, dash style, and
    the like) of the line to be drawn
  • the GraphicsFillRectangle method
  • can use a LinearGradientBrush object
  • to fill a rectangle with a gradually changing
    color
  • Font and StringFormat objects influence the way a
    Graphics object draws text
  • a Matrix object stores and manipulates the world
    transformation of a Graphics object
  • used to rotate, scale, and flip images.

9
the Graphics class
  • provides methods for drawing lines, curves,
    figures, images, and text
  • stores attributes of the display device and
    attributes of the items to be drawn
  • encapsulates a GDI drawing surface and is
    associated with a specific device context
  • How to get a Graphics object
  • call the Control.CreateGraphics method on an
    object that inherits from System.Windows.Forms.Con
    trol
  • handle a control's Control.Paint event and access
    the Graphics property of the System.Windows.Forms.
    PaintEventArgs class

10
the GDI class interface
  • some classes serve primarily as structured data
    types
  • i.e., Rectangle, Point, and Size are for general
    purposes
  • others are specialized and are considered helper
    classes
  • i.e., the BitmapData class is a helper for the
    Bitmap class
  • the PathData class is a helper for the
    GraphicsPath class
  • GDI defines a few structures for organizing data
  • i.e., the ColorMap structure holds a pair of
    Color objects that form one entry in a color
    conversion table.
  • GDI defines several enumerations
  • the LineJoin enumeration contains
  • LineJoinBevel, LineJoinMiter, and LineJoinRound
  • styles that can be used to join two lines

11
sample programs and code snippets
  • showdate
  • gradient picker (and project 1)
  • line drawing program
  • ImageList control
  • how to embed bitmaps
  • PictureBox control
  • drawing bitmaps directly in OnPaint()

12
the end of this PowerPoint file
Hooray!
Write a Comment
User Comments (0)
About PowerShow.com