Programming the .NET Compact Framework in C# By Paul Yao & David Durant
Chapter 15 – Compact Framework Graphics Page 4 11/7/2003
Copyright © 2002-2003 Paul Yao & David Durant
2 Printer [Comment 15.16]
3 Bitmap
[Comment 15.17]
4 Metafile
[Comment 15.18]
When we use the term 'drawing surface', we mean either a physical or logical drawing surface.
Two of the four drawing surfaces in the list are physical drawing surfaces, which require
dedicated device drivers: display screens and printers. The other two drawing surfaces are
logical drawing surfaces: bitmaps and metafiles. These latter two store pictures for eventual
output to a device. [Comment 15.19]
Bitmaps and metafiles are similar enough that they share a common base class in the
desktop .NET Framework: the Image
3
class. Metafiles are not officially supported in Windows
CE, however, and so its wrapper, the Metafile
4
class, does not exist in the current version of
the Compact Framework. Because metafiles might someday be supported in a future version of
the Compact Framework, they are worth a brief mention here. [Comment 15.20]
Display Screen
The display screen plays a central role in all GUI environments, for it is on the display screen
where a user interacts with the various GUI applications. The real stars of the display screen are
the windows, after which the operating system gets its very name. A window acts as a
virtual
console
5
for interacting with a user. The physical console for a desktop PC consists of a display
screen, a mouse, and a keyboard. On a Pocket PC, the physical console is made up of a display
screen, a stylus and touch-sensitive screen for pointing, and hardware buttons for input
(supported, of course, by the on-screen keyboard. [Comment 15.21]
All graphical output on the display screen is directed to one window or another. Enforcement
of window boundaries relies on
clipping. Clipping is the establishment and enforcement of
drawing boundaries; a program can draw inside clipping boundaries but not outside them. The
simplest clipping boundaries are a rectangle. The area inside a window where a program may
draw is referred to as the window's
client area. [Comment 15.22]
Printer
Printers are the best established and most connected peripheral in the world of computers.
While some industry pundits rant about the soon-to-arrive future paperless office, just the
opposite has occurred. Demand for printed output has continued to go up, not down. Perhaps the
world of computers – with its flashing LCD displays, volatile RAM, and every-shrinking silicon –
makes a person want something that is more real. [Comment 15.23]
Printing from Windows CE-powered devices is still in its infancy. Perhaps users can print
what they want from desktop PCs. Or maybe the problem is that programs bundled with a Pocket
PC – programs like Pocket Word and Pocket Excel – do not support printing. Whatever the
cause, we show you several ways to print in chapter 18 (
Printing), so that you can decide
whether the results are worth the effort. [Comment 15.24]
Bitmap
Bitmaps provide a way to store a picture. Like its desktop counterparts, Windows CE
supports device-independent bitmaps (DIBs) as first-class citizens. In-memory bitmaps can be
created of any size
6
, and treated like any other drawing surface. After a program has drawn to a
bitmap, that image can be put on the display screen. [Comment 15.25]
If you look closely, you can see that Windows CE – and the Compact Framework – support
other raster formats. Supported formats include GIF, PNG, and JPEG. When Visual Studio .NET
reads files with these formats – which it uses for inclusion in image lists, for example – it converts
the raster data to a bitmap. The same occurs when a PNG or JPEG file is read from the object
store into a Compact Framework program. Whatever external format is used for raster data,
3
Fully-qualified name: System.Drawing.Image.
4
Fully-qualified name: System.Drawing.Imaging.Metafile.
5
A term we first heard from Marlin Eller, a member of the GDI team for Windows 1.x.
6
The limitation on bitmap size is available system memory.