Cover image for Windows 2000 Graphics API black book
Windows 2000 Graphics API black book
Chandler, Damon.
Personal Author:
Publication Information:
Scottsdale, Ariz. : Coriolis, [2001]

Physical Description:
xxxiii, 1188 pages : illustrations ; 24 cm + 1 computer optical disc (4 3/4 in.).
General Note:
Includes index.
Subject Term:
Added Author:
Format :


Call Number
Material Type
Home Location
Item Holds
T385 .C452 2001 Book and Software Set Central Closed Stacks

On Order



This guide covers how to use the GDI functions including Windows 2000-specific GDI functions, such as the new alpha blending support, and creating advanced user interfaces. Teaches how to control Windows bitmaps, reliably render/capture images to the printer and other devices, and compressing and decompressing images.

Author Notes

Damon Chandler holds a B.S. in biomedical engineering and a M.Eng in electriccal engineering. He develops Windows and X-Windows applications at the Cornell Visual Communications Lab, where he's currently researching new medical image compression algorithms, Damon is also a member of Borland's TeamB.
Michael Fotsch is a freelance developer who specializes in DirectX technology. He has more than 15 years experience in developing games and other graphics intensive applications.

Table of Contents

Introductionp. xxviii
Part I The Windows GDI
Chapter 1 Device Contextsp. 3
Types of Device Contextsp. 4
Device Context Attributesp. 7
The WM_PAINT Messagep. 22
The WM_ERASEBKGND Messagep. 28
Saving and Restoring a Device Contextp. 30
Using a Private Device Context for Speedp. 33
Bit-Block Transferp. 36
Memory Device Contextsp. 39
Obtaining a Handle to a Display Device Contextp. 45
Extracting Information from a Device Contextp. 51
Retrieving and Manipulating a Device Context's Attributesp. 55
Working with Memory Device Contextsp. 63
Transferring Bitsp. 68
Chapter 2 The Brush Objectp. 83
Types of Brushesp. 84
The LOGBRUSH Structurep. 88
The Brush Originp. 90
Rendering with a Brush Objectp. 91
Creating a Solid Brushp. 100
Creating a Hatch Brushp. 102
Creating a Pattern Brush from a DDBp. 103
Creating a Pattern Brush from a DIBp. 105
Creating a Transparent Brushp. 107
Obtaining a Handle to a Stock Brushp. 108
Obtaining a Handle to a System Brushp. 109
Retrieving the Attributes of a Brushp. 111
Changing the Color of a Brushp. 113
Chapter 3 The Pen Objectp. 115
Types of Pensp. 116
Extended and Non-Extended Pensp. 118
Logical Pen Structuresp. 122
Rendering with a Logical Penp. 126
Working with Non-Extended Pensp. 135
Working with Extended Pensp. 139
Obtaining and Changing Pen Attributesp. 146
Chapter 4 The Font Objectp. 151
Windows Font Supportp. 152
Logical Fontsp. 154
Creating a Logical Fontp. 174
Creating a Rotated Fontp. 178
Obtaining the Handle to a Stock Fontp. 180
Determining the Width of a Characterp. 180
Determining the Width and Height of a Stringp. 182
Enumerating the Available Fonts for a Specific Devicep. 183
Retrieving the Text Capabilities of a Devicep. 190
Rendering Aligned Textp. 191
Rendering Disabled Textp. 193
Rendering a String Containing Multiple Fontsp. 194
Using Masking to Render Reverse-Colored Textp. 198
Using Masking to Render Textured Textp. 202
Chapter 5 Lines, Curves, and Shapesp. 207
Output Primitivesp. 209
The Polygon Fill Modep. 229
Hit-Testingp. 230
Rendering Lines, Curves, and Shapesp. 241
Hit-Testing Lines, Curves, and Shapesp. 267
Output-Primitive-Related Modes and Capabilitiesp. 281
Chapter 6 The Bitmap Objectp. 287
A Compatible Bitmapp. 288
The BITMAP Structurep. 290
Rendering DDBsp. 292
DDBs vs. DIBsp. 300
Creating a Monochrome Device-Dependent Bitmapp. 307
Creating a Color Device-Dependent Bitmapp. 311
Creating a Device-Dependent Bitmap from a Device-Independent Bitmapp. 315
Copying a Device-Dependent Bitmapp. 321
Loading a Device-Dependent Bitmap from a Filep. 323
Saving a Device-Dependent Bitmap to a Filep. 329
Retrieving the Dimensions and Color Depth of a Device-Dependent Bitmapp. 331
Manipulating the Bits of a Device-Dependent Bitmapp. 332
Rendering a Device-Dependent Bitmapp. 338
Rendering a Device-Dependent Bitmap in a Scaled Fashionp. 341
Rendering the Mirror Image of a Device-Dependent Bitmapp. 344
Rendering a Transparent Device-Dependent Bitmapp. 347
Chapter 7 Device-Independent Bitmapsp. 355
A "Universal" Formatp. 356
A Hybrid Object: The DIB Section Bitmapp. 386
Creating a Device-Independent Bitmapp. 391
Creating a Device-Independent Bitmap from a Device-Dependent Bitmapp. 396
Loading a Device-Independent Bitmap from a Filep. 405
Saving a Device-Independent Bitmap to a Filep. 409
Rendering a Device-Independent Bitmapp. 412
Rendering a Device-Independent Bitmap in a Scaled Fashionp. 415
Creating a Palette from the Color Table of a Device-Independent Bitmapp. 418
Accessing the Pixels of a Packed Device-Independent Bitmapp. 421
Creating a DIB Section Bitmapp. 424
Creating a DIB Section Bitmap from a Device-Dependent Bitmapp. 426
Loading a DIB Section Bitmap from a Filep. 427
Saving a DIB Section Bitmap to a Filep. 432
Retrieving Information about a DIB Section Bitmapp. 432
Rendering a DIB Section Bitmapp. 433
Changing the Color-Table Entries of a DIB Section Bitmapp. 435
Chapter 8 Regions and Pathsp. 437
A Defined Territoryp. 438
A Recorded Journeyp. 448
Creating and Managing Regionsp. 464
Creating and Working with Pathsp. 486
Chapter 9 Palettesp. 499
A Device-Specific Color Tablep. 500
The Palette Managerp. 501
Palette-Related Messagesp. 509
Palette-Based vs. Non-Palette-Based Devicesp. 522
Palettes, Bitmaps, and Memory Device Contextsp. 523
Creating a Logical Palettep. 526
Selecting a Logical Palette into a Device Contextp. 527
Realizing a Logical Palettep. 529
Retrieving the Entries of a Logical Palettep. 530
Manipulating the Entries of a Logical Palettep. 532
Retrieving the Entries of the System Palettep. 533
Modifying the System Palette's Static Entriesp. 536
Determining if a Device Uses a Palettep. 538
Handling the WM_QUERYNEWPALETTE Messagep. 539
Handling the MW_PALETTECHANGED Messagep. 540
Chapter 10 Coordinate Spacesp. 545
GDI Coordinate Spacesp. 548
Coordinate-Space Transformationsp. 551
Retrieving and Changing a Device Context's Graphics Modep. 573
Retrieving a Device Context's World-Space to Page-Space Transformationp. 574
Setting a Device Context's World-Space to Page-Space Transformationp. 575
Modifying a Device Context's World-Space to Page-Space Transformationp. 577
Retrieving a Device Context's Window Originp. 579
Changing a Device Context's Window Originp. 580
Retrieving a Device Context's Viewport Originp. 581
Changing a Device Context's Viewport Originp. 582
Retrieving a Device Context's Window Extentsp. 583
Changing a Device Context's Window Extentsp. 584
Retrieving a Device Context's Viewport Extentsp. 585
Changing a Device Context's Viewport Extentsp. 587
Part II DirectDraw
Chapter 11 The IDirectDraw7 Interfacep. 591
An Overview of DirectDrawp. 592
COM Essentialsp. 597
Using DirectDrawp. 600
Using DirectDrawCreateEx to Create a DirectDraw Objectp. 613
Using CoCreateInstance to Create a DirectDraw Objectp. 614
Working with Previous Versions of DirectDrawp. 616
Enumerating Available Display Devicesp. 618
Setting the Cooperative Levelp. 623
Setting the Cooperative Level for Multimonitor Applicationsp. 624
Handling Task Switches and Display-Mode Changesp. 625
Setting Up a Windowed Applicationp. 628
Setting Up a Full-Screen Applicationp. 632
Creating a Surfacep. 634
Creating a Palettep. 636
Creating a Clipperp. 637
Determining the Capabilities of the Video Hardwarep. 638
Using the DDCapsViewer Programp. 641
Retrieving the Driver Name and Versionp. 645
Querying the Amount of Available Video Memoryp. 646
IDirectDraw7-Related Error Codesp. 648
Chapter 12 DirectDraw Display Modesp. 651
An Overview of Display Modesp. 652
Working with Display Modesp. 654
Working with the Vertical Blankp. 661
Dialog Boxes in Full-Screen Modep. 663
Setting the Display Modep. 665
Enumerating the Supported Display Modesp. 666
Checking Whether a Mode Is Availablep. 670
Using Mode X and Mode 13p. 673
Determining which Mode Is Currently Setp. 676
Restoring the Display Modep. 677
Retrieving the Refresh Ratep. 677
Calculating the Refresh Ratep. 678
Synchronizing with the Vertical Blankp. 680
Displaying a Dialog Box in Full-Screen Modep. 682
Chapter 13 DirectDraw Surfacesp. 687
What's a DirectDraw Surface?p. 689
Concepts and Terminologyp. 690
Surface Creationp. 695
Combining DirectDraw and the GDIp. 699
Surface Blit Operationsp. 701
Accessing Surface Memory Directlyp. 707
Working with Flipping Chainsp. 714
Working with Overlay Surfacesp. 722
Losing and Restoring Surfacesp. 727
Interpreting the DDSURFACEDESC2 Structurep. 730
Interpreting the DDPIXELFORMAT Structurep. 733
Interpreting the DDSCAPS2 Structurep. 736
Creating a Non-Flipping Primary Surfacep. 737
Creating a Primary Surface Flipping Chainp. 739
Using the Flip Methodp. 740
Retrieving a Pointer to an Attached Surfacep. 741
Creating an Off-Screen Surfacep. 742
Creating an Off-Screen Surface from an Existing Block of Memoryp. 744
Creating an Off-Screen Flipping Chainp. 746
Retrieving an HDC Handle for a Surfacep. 747
Loading a Bitmap File into a Surfacep. 748
Loading a Sequence of Bitmaps into a Flipping Chainp. 750
Blitting by Using the Blt Methodp. 752
Blitting by Using the BltFast Methodp. 754
Setting the Color Key of a Surfacep. 756
Retrieving the Color Key of a Surfacep. 757
Requesting Blit Effects with the DDBLTFX Structurep. 758
Locking a Surface to Access its Frame Buffer Directlyp. 759
Unlocking a Surfacep. 761
Converting an RGB Triple into the Surface's Pixel Formatp. 761
Decoding a Pixel into an RGB Triplep. 763
Querying Surface Characteristicsp. 764
Creating a Stereo Vision Flipping Chainp. 765
Creating an Overlay Surfacep. 766
Using the UpdateOverlay Methodp. 767
Displaying or Hiding an Overlay Surfacep. 769
Enumerating Surfacesp. 770
Finding Out which Surfaces Can Be Createdp. 771
Retrieving Supported FOURCC Formatsp. 773
Accessing a FOURCC Surface Directlyp. 774
Determining Whether a Surface Is Lostp. 776
Restoring a Surfacep. 776
Chapter 14 DirectDraw Clippersp. 779
An Overview of Clippersp. 780
Creating Clippersp. 782
Working with the Clip Listp. 783
Performing Clipped Blitsp. 786
Clipping When Accessing Surface Memory Directlyp. 788
Using CoCreateInstance to Create a Clipper Objectp. 791
Creating an Independent Clipper Objectp. 792
Attaching a Clipper to a Surfacep. 793
Detaching a Clipper from a Surfacep. 794
Retrieving the Currently Attached Clipperp. 794
Setting the Clip Listp. 795
Initializing the Clip List with a GDI Regionp. 795
Associating a Clipper with a Windowp. 796
Retrieving the Clip Listp. 797
Creating a GDI Region from a Clip Listp. 798
Performing Clipped Blits with the BltFast Methodp. 800
Chapter 15 DirectDraw Colors and Palettesp. 803
Working with DirectDraw Palettesp. 804
Working with Color Controlsp. 810
Working with Gamma Controlsp. 814
Creating a Palettep. 819
Setting Up a Palette for a Windowed Applicationp. 820
Changing the Palette Entriesp. 821
Querying the Palette Entriesp. 822
Attaching a Palette to a Surfacep. 823
Blending Between Palettesp. 824
Obtaining a Pointer to an IDirectDrawColorControl Interfacep. 825
Setting the Color Controlsp. 826
Querying the Color Controlsp. 828
Obtaining a Pointer to an IDirectDrawGammaControl Interfacep. 829
Setting the Gamma Rampsp. 830
Querying the Gamma Rampsp. 831
Part III Image Support
Chapter 16 Image Color Managementp. 835
Colors and the HVSp. 836
Color Management Systemsp. 843
Using ICM 2p. 854
Profiled Bitmapsp. 886
Creating a Color Profile Objectp. 895
Creating a Color Transform Objectp. 897
Color-Matching a Bitmapp. 899
Proofing a Bitmapp. 901
Reading an ICM-Aware Bitmap from a Filep. 913
Saving an ICM-Aware Bitmap to a Filep. 918
Embedding Profile Information in a Bitmapp. 924
Locating the Color Folderp. 926
Using the ICM Common Dialogp. 927
Chapter 17 Image Manipulationp. 935
The GBuffer Classp. 936
The GBufferList Classp. 939
Point Processingp. 940
Filteringp. 950
Geometric Manipulationsp. 986
Converting an Image to Grayscalep. 1010
Thresholding an Imagep. 1011
Brightening or Darkening an Imagep. 1013
Computing the Histogram of an Imagep. 1014
Contrast-Stretching an Imagep. 1016
Histogram-Equalizing an Imagep. 1020
Computing the Discrete Cosine Transform of an Imagep. 1022
Computing the Inverse Discrete Cosine Transformp. 1024
Filtering an Image in the Spatial Domainp. 1027
Computing the Discrete Wavelet Transform of an Imagep. 1032
Computing the Inverse Discrete Wavelet Transformp. 1035
Warping an Imagep. 1038
Morphing Two Imagesp. 1039
Initializing a GBuffer Object with the Pixels of a DIB Section Bitmapp. 1041
Initializing a DIB Section Bitmap with the Pixels of a GBuffer Objectp. 1042
Chapter 18 Image File Formatsp. 1045
JPEG Imagesp. 1047
PNG Imagesp. 1062
Reading a JPEG Image from a Filep. 1114
Writing a JPEG Image to a Filep. 1119
Reading a PNG Image from a Filep. 1124
Writing a PNG Image to a Filep. 1133
Part IV Appendixes
Appendix A A Brief Review of Matrices and Vectorsp. 1145
Appendix B Other Resourcesp. 1155
Indexp. 1161