C#图形编程

默认坐标系

在二维空间里,C#和GDI+图形库有三个默认的坐标系统:世界(world)、页面(page)、设备(device)。世界坐标系是用来为特定的图形世界建模;页面坐标系用来在窗体、控件上绘制图形;设备坐标系用来在物理的设备上,如计算机屏幕、纸等。当你让C#从点(X1,Y1)到(X2,Y2)绘制一条直线,这个点在世界坐标系里。

你不能用世界坐标系在计算机屏幕上直接绘制图形对象。你需要做一系列的转换。一个转换是世界坐标系转换,即将时间坐标系转换为页面坐标系;另一个是页面转换,将页面坐标系转换为设备坐标系。

一般情况下,这三个坐标系的起到是点(0,0),即位于绘图区域的左上角。

这三个坐标系的默认单位是像素。

This Wrox Blox teaches you how to add graphics to C# 2008 applications, explaining fundamental graphics techniques such as: drawing shapes with different colors and line styles; filling areas with colors, gradients, and patterns; drawing text that is properly aligned, sized, and clipped exactly where you want it; manipulating images and saving results in bitmap, JPEG, and other types of files. Also covered are instructions for how to greatly increase your graphics capabilities using transformations. Transformations allow you to move, stretch, or rotate graphics. They also let you work in coordinate systems that make sense for your application. You will also learn how to use all of these techniques in printouts. The author describes the sequence of events that produce a printout and shows how to generate and preview printouts. The final sections describe two powerful new graphic tools that were introduced with .NET Framework 3.0: WPF graphics and FlowDocuments. WPF applications can use XAML graphic commands to declaratively draw and fill the same kinds of shapes that a program can draw by using graphics objects. Finally, a discussion on the FlowDocument object shows you how to define items that should be flowed across multiple pages as space permits. This lets you display text, graphics, controls, and other items that automatically flow across page breaks. FlowDocument viewers make displaying these documents easy for you, and simplifies the user's reading of the documents. This Wrox Blox also contains 35 example programs written in C# 2008, although most of the code works in previous versions of C# as well. The most notable exceptions are WPF graphics and FlowDocuments, both of which require WPF provided in .NET Framework 3.0 and later.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值