Graphics Programming with GDI+
暫譯: 使用 GDI+ 的圖形程式設計

Mahesh Chand

  • 出版商: Addison Wesley
  • 出版日期: 2003-10-20
  • 售價: $2,540
  • 貴賓價: 9.5$2,413
  • 語言: 英文
  • 頁數: 784
  • 裝訂: Paperback
  • ISBN: 0321160770
  • ISBN-13: 9780321160775
  • 已絕版

買這商品的人也買了...

相關主題

商品描述

Graphics Programming with GDI+ is the .NET developer's guide to writing graphics applications for Windows and the Web. Through the use of detailed examples it provides experienced programmers with a deep understanding of the entire GDI+ API defined in the .NET Framework class library.

The book begins with an introduction to GDI+ and the basics of graphics programming in Windows. The core of the book is a hands-on guide to practical topics, including how to use Windows Forms and optimize GDI+ performance. Chapters demonstrate how to develop real-world tools such as GDI+Painter, GDI+Editor, ImageViewer, and ImageAnimator. The author provides extensive reusable sample code in C# throughout, and complete downloadable source code in C# and Visual Basic .NET is available online, as are color versions of screen shots from the book.

Key topics include:

  • How GDI+ compares to GDI
  • How GDI+ is defined and used in the .NET Framework
  • How to draw, paint, and fill graphics objects
  • Viewing and manipulating images
  • Transforming graphics objects, images, and colors
  • Printing in .NET
  • How to develop GDI+ Web applications
  • How to optimize drawing quality and performance
  • Interactive color blending and transparent colors
  • GDI interoperability
  • Answers to frequently asked GDI+ questions

Graphics Programming in GDI+ is the most in-depth treatment available on writing effective graphics applications for the .NET Framework.

Table of Contents

Figures.


Tables.


Acknowledgments.


Introduction.


1. GDI+: The Next-Generation Graphics Interface.

Understanding GDI+.

Definition.

What Is GDI+?

The GDI+ Library in the .NET Framework.

What's New in GDI+ for GDI Programmers?

Exploring GDI+ Functionality.

2D Vector Graphics Programming.

Imaging.

Typography.

Printing.

Design.

GDI+ from a GDI Perspective.

Elimination of Handles and Device Contexts.

Object-Oriented Approach.

Graphics Object Independence.

Method Overloading.

Draw and Fill Methods.

Regions and Their Styles.

GDI+ Namespaces and Classes in .NET.

The System.Drawing Namespace.

The System.Drawing.Design Namespace.

The System.Drawing.Drawing2D Namespace.

The System.Drawing.Imaging Namespace.

The System.Drawing.Printing Namespace.

The System.Drawing.Text Namespace.

Summary.



2. Your First GDI+ Application.

Drawing Surfaces.

Forms as a Surface.

Printers as a Surface.

Bitmaps as a Surface.

The Coordinate System.

The Cartesian Coordinate System.

The Default GDI+ Coordinate System.

Tutorial: Your First GDI+ Application.

Creating a Windows Application.

Adding a Reference to GDI+.

Getting a Graphics Object in an Application.

Creating Pens and Brushes.

Drawing Graphics Shapes.

Releasing Objects.

Building and Running the Application.

Some Basic GDI+ Objects.

The Color Structure.

The Point and PointF Structures.

The Rectangle and RectangleF Structures.

The Size and SizeF Structures.

Summary.



3. The Graphics Class.

Graphics Class Properties.

Graphics Class Methods.

Draw Methods.

Fill Methods.

Miscellaneous Graphics Class Methods.

The GDI+Painter Application.

Drawing a Pie Chart.

Summary.



4. Working with Brushes and Pens.

Understanding and Using Brushes.

The Brush Class.

The Brushes Class.

Solid Brushes.

Hatch Brushes.

Texture Brushes.

Gradient Brushes.

Using Pens in GDI+.

Creating Pens.

Pen Class Properties and Methods.

Pen Types.

Pens Example.

Pen Alignment.

LineCap, DashCap, and DashStyle.

Drawing Other Graphics Shapes by Applying Cap and Dashed Line Styles.

Transformation with Pens.

Transformation with Brushes.

System Pens and System Brushes.

System Pens.

System Brushes.

A Real-World Example: Adding Colors, Pens, and Brushes to the GDI+Painter Application.

Improvements in GDI+Painter.

Summary.



5. Colors, Fonts, and Text.

Accessing the Graphics Object.

Working with Colors.

Color Spaces.

The Color Structure.

System Colors.

The ColorConverter and ColorTranslator Classes.

Working with Fonts.

Font Types in Windows.

Fonts in .NET.

The FontStyle Enumeration.

The FontFamily Class.

The GraphicsUnit Enumeration.

The Font Class.

Constructing a Font Object.

Working with Text and Strings.

Drawing Formatted Text.

Using Tab Stops.

The FormatFlags Property.

Setting Digital Substitution.

Rendering Text with Quality and Performance.

Advanced Typography.

Getting All Installed Fonts on a System.

Private Font Collection.

A Simple Text Editor.

Transforming Text.

Summary.



6. Rectangles and Regions.

The Rectangle Structure.

Constructing a Rectangle Object.

Constructing a RectangleF Object.

Rectangle Properties and Methods.

The Region Class.

Constructing a Region Object.

The Complement, Exclude, and Union Methods.

The Xor and Intersect Methods.

GetBounds and Other Methods.

Regions and Clipping.

Clipping Regions Example.

Regions, Nonrectangular Forms, and Controls.

The Application.

Coding.

Summary.



7. Working with Images.

Raster and Vector Images.

Raster Image Formats.

Graphics File Formats.

Working with Images.

An Image Viewer Application.

Creating an Image Object.

Drawing an Image.

Saving Images.

Retrieving Image Properties.

Manipulating Images.

Creating a Thumbnail of an Image.

Rotating and Flipping Images.

Adding Rotate and Flip Options to the Image Viewer.

Fitting Images.

Zooming In and Out.

Playing Animations in GDI+.

Working with Bitmaps.

Creating a Bitmap Object.

Viewing a Bitmap.

The Bitmap Class Methods and Properties.

Working with Icons.

Skewing Images.

Drawing Transparent Graphics Objects.

Viewing Multiple Images.

Using a Picture Box to View Images.

Saving Images with Different Sizes.

Summary.



8. Advanced Imaging.

Rendering Partial Bitmaps.

Drawing Grayscale or Other Color Images.

Using BitmapData to Change Pixel Format.

Working with Metafiles.

Metafile Class Method.

Creating Metafiles Programmatically.

Enhanced Metafiles.

How Metafiles Work.

Reading a Metafile Header.

Color Mapping Using Color Objects.

The Color Remap Table.

The Color Matrix.

The Color Palette.

Image Attributes and the ImageAttributes Class.

The SetWrapMode Method.

The SetGamma Method.

The SetColorMatrix Method.

The SetNoOp and SetColorKey Methods.

The SetThreshold Method.

The SetBrushRemapTable Method.

The Clear Methods.

Encoder Parameters and Image Formats.

The Encoder, EncoderCollection, and Image Relationship.

The Encoder and EncoderParameter Classes.

Retrieving Information from Digital Images or Tagged Data of TIFF Files.

Converting a Bitmap to Other Formats.

Summary.



9. Advanced 2D Graphics.

Line Caps and Line Styles 9.1.1 Line Caps and Styles Specified by the Pen Class.

Adding Line Caps and Styles.

Getting and Setting Line Caps and Styles.

Drawing Other Objects with Line Caps and Styles.

Customizing Line Caps.

Understanding and Using Graphics Paths.

Creating a GraphicsPath Object.

Shaped Forms and Graphics Paths.

GraphicsPath Properties and Methods.

Subpaths.

The Graphics Path Iterator.

Graphics Containers.

Understanding Graphics States.

Saving and Restoring Graphics States.

Working with Graphics Containers.

Reading Metadata of Images.

Blending Explained.

Color Blending.

Blending Using LinearGradientBrush Objects.

Adding Multicolor Support to Gradients.

Using Gamma Correction in Linear Gradient Brushes.

Blending Using PathGradientBrush Objects.

Alpha Blending.

Brushes, Pens, and Alpha Blending.

Alpha Blending and Images.

Compositing Mode and Blending.

Mixed Blending.

Miscellaneous Advanced 2D Topics.

Region Data.

The SmoothingMode and PixelOffsetMode Enumerations.

Summary.



10. Transformation.

Coordinate Systems.

Transformation Types.

The Matrix Class and Transformation.

The Graphics Class and Transformation.

Global, Local, and Composite Transformations.

Image Transformation.

Color Transformation and the Color Matrix.

The ColorMatrix Class.

Matrix Operations in Image Processing.

Translating Colors.

Scaling Colors.

Shearing Colors.

Rotating Colors.

Text Transformation.

The Significance of Transformation Order.

Summary.



11. Printing.

A Brief History of Printing with Microsoft Windows.

Hewlett-Packard Chooses Standards.

Overview of the Printing Process.

How Is Drawing Different from Printing?

Conceptual Flow of the Printing Process.

Programmatic Flow of the Printing Process.

The System.Drawing.Printing Namespace.

Your First Printing Application.

Printer Settings.

The PrinterSettings Class.

The PaperSize Class.

The PaperSource Class.

The PrinterResolutionKind Enumeration.

PrinterSettings Collection Classes.

A Printer Settings Example.

The PrintDocument and Print Events.

Understanding Print Events.

Printing Text.

Printing Graphics.

Printing Graphics Items.

Printing Images.

Print Dialogs.

The PrintDialog Control.

The PageSetupDialog Control.

The PrintPreviewDialog Control.

Print Dialogs in Action.

Customizing Page Settings.

The PageSettings Class.

Page Margins.

Creating a Custom Paper Size.

The PaperKind Enumeration.

The PaperSourceKind Enumeration.

Page Settings in Action.

The PrintRange Enumeration.

Printing Multiple Pages.

The DocumentName Property.

Marginal Printing: A Caution.

Getting into the Details: Custom Controlling and the Print Controller.

Summary.



12. Developing GDI+ Web Applications.

Creating Your First ASP.NET Web Application.

Creating a Web Application Project.

Adding Web Controls to a Web Form.

Writing Code on the Button Click Event Handler.

Your First Graphics Web Application.

How Does It Work?

Understanding the Save Method.

Drawing Simple Graphics.

Drawing Images on the Web.

Setting Image Quality.

Using LinearGradientBrush and PathGradientBrussh.

Drawing Transparent Graphics Objects.

Drawing a Line Chart.

The ChartComp Component.

The Client Application.

Drawing a Pie Chart.

Summary.



13. GDI+ Best Practices and Performance Techniques.

Understanding the Rendering Process.

Understanding the Paint Event.

Adding a Paint Event Handler to a Form.

Adding a Paint Event Handler to Windows Controls.

Overriding the OnPaint Method of a Form.

Using VS.NET to Add the Paint Event Handler.

Disposing of Graphics Objects.

The OnPaintBackground Method.

Scope and Type of Variables and Performance.

Double Buffering and Flicker-Free Drawing.

Understanding the SetStyle Method.

The Quality and Performance of Drawing.

Repaint Only the Required Area.

Use Graphics Paths.

Select Methods Carefully.

Avoid Using Frequently Called Events.

Use System Brushes and Pens.

Avoid Automatic Scaling of Images.

Summary.



14. GDI Interoperability.

Using GDI in the Managed Environment.

The DllImportAttribute Class.

Using the BitBlt Function.

Using GDI Print Functionality.

Cautions for Using GDI in Managed Code.

No GDI Calls between GetHdc and ReleaseHdc.

Using GDI on a GDI+ Graphics Object Backed by a Bitmap.

Summary.



15. Miscellaneous GDI+ Examples.

Designing Interactive GUI Applications.

Understanding the Control Class.

The Application.

Drawing Transparent Controls.

Drawing Shaped Forms and Windows Controls.

Adding Copyright Information to a Drawn Image.

Reading and Writing Images to and from a Stream or Database.

Creating Owner-Drawn List Controls.

The DrawItem Event.

The MeasureItem Event.

Owner-Drawn ListBox Controls.

An Owner-Drawn Image ListBox Control.

Summary.



Appendix A: Exception Handling in .NET.

Why Exception Handling?

Understanding the try…catch Block.

The try…catch Statement.

The try…catch…finally Statement.

Nested try…catch Statements.

Multiple catch Statements with a Single try Statement.

Understanding Exception Classes.

The Exception Class: Mother of All Exceptions.

Other Exception Classes.

Summary.

商品描述(中文翻譯)

《使用 GDI+ 的圖形程式設計》是 .NET 開發者撰寫 Windows 和網頁圖形應用程式的指南。透過詳細的範例,它為經驗豐富的程式設計師提供了對 .NET Framework 類別庫中整個 GDI+ API 的深入理解。

本書首先介紹 GDI+ 及 Windows 圖形程式設計的基本概念。書中的核心內容是針對實用主題的實作指南,包括如何使用 Windows Forms 及優化 GDI+ 的效能。各章節展示如何開發實際的工具,例如 GDI+Painter、GDI+Editor、ImageViewer 和 ImageAnimator。作者在全書中提供了大量可重用的 C# 範例程式碼,並且完整的 C# 和 Visual Basic .NET 可下載原始碼也可在線獲得,還有書中截圖的彩色版本。

主要主題包括:
- GDI+ 與 GDI 的比較
- GDI+ 在 .NET Framework 中的定義與使用
- 如何繪製、填充圖形物件
- 查看與操作影像
- 轉換圖形物件、影像和顏色
- 在 .NET 中列印
- 如何開發 GDI+ 網頁應用程式
- 如何優化繪圖品質和效能
- 互動式顏色混合和透明顏色
- GDI 互操作性
- 常見的 GDI+ 問題解答

《使用 GDI+ 的圖形程式設計》是撰寫有效圖形應用程式的最深入的著作,專為 .NET Framework 而設。

**目錄**
**圖表。**
**表格。**
**致謝。**
**導言。**
**1. GDI+: 下一代圖形介面。**

理解 GDI+。

定義。

什麼是 GDI+?

.NET Framework 中的 GDI+ 函式庫。

對 GDI 程式設計師來說 GDI+ 有什麼新特性?

探索 GDI+ 功能。

2D 向量圖形程式設計。

影像處理。

排版。

列印。

設計。

從 GDI 的角度看 GDI+。

消除句柄和設備上下文。

物件導向方法。

圖形物件獨立性。

方法重載。

繪製和填充方法。

區域及其樣式。

.NET 中的 GDI+ 命名空間和類別。

System.Drawing 命名空間。

System.Drawing.Design 命名空間。

System.Drawing.Drawing2D 命名空間。

System.Drawing.Imaging 命名空間。

System.Drawing.Printing 命名空間。

System.Drawing.Text 命名空間。

總結。

**2. 你的第一個 GDI+ 應用程式。**

繪圖表面。

表單作為表面。

印表機作為表面。

位圖作為表面。

坐標系統。

笛卡爾坐標系統。

預設的 GDI+ 坐標系統。

教學:你的第一個 GDI+ 應用程式。

創建 Windows 應用程式。

添加對 GDI+ 的引用。

在應用程式中獲取圖形物件。

創建筆和畫刷。

繪製圖形形狀。

釋放物件。

構建和運行應用程式。

一些基本的 GDI+ 物件。

顏色結構。

Point 和 PointF 結構。

Rectangle 和 RectangleF 結構。

Size 和 SizeF 結構。

總結。

**3. Graphics 類別。**

Graphics 類別屬性。

Graphics 類別方法。

繪製方法。

填充方法。

雜項 Graphics 類別方法。

GDI+Painter 應用程式。

繪製圓餅圖。

總結。

**4. 使用畫刷和筆。**

理解和使用畫刷。

Brush 類別。

Brushes 類別。

實心畫刷。

斜紋畫刷。

紋理畫刷。

漸層畫刷。

在 GDI+ 中使用筆。

創建筆。

Pen 類別屬性和方法。

筆的類型。

筆的範例。

筆的對齊。

LineCap、DashCap 和 DashStyle。

通過應用 Cap 和 虛線樣式繪製其他圖形形狀。

使用筆進行轉換。

使用畫刷進行轉換。

系統筆和系統畫刷。

系統筆。

系統畫刷。

實際範例:將顏色、筆和畫刷添加到 GDI+Painter 應用程式中。

GDI+Painter 的改進。

總結。

**5. 顏色、字型和文字。**

訪問圖形物件。

處理顏色。

顏色空間。

顏色結構。

系統顏色。

ColorConverter 和 ColorTranslator 類別。

處理字型。

Windows 中的字型類型。

.NET 中的字型。

FontStyle 列舉。

FontFamily 類別。

GraphicsUnit 列舉。

Font 類別。

構建字型物件。

處理文字和字串。

繪製格式化文字。

使用制表位。

FormatFlags 屬性。

設置數字替代。

以品質和效能渲染文字。

進階排版。

獲取系統上所有已安裝的字型。

私有字型集合。

簡單的文字編輯器。

轉換文字。

總結。

**6. 矩形和區域。**

Rectangle 結構。

構建矩形物件。

構建 RectangleF 物件。

矩形屬性和方法。

Region 類別。

構建區域物件。

Complement、Exclude 和 Union 方法。

Xor 和 Intersect 方法。

GetBounds 和其他方法。

區域和剪裁。

剪裁區域。