C#图形编程GDI+基础

本文介绍了C#中使用GDI+进行图形编程的基础知识,包括GDI+的对象和函数,以及创建Graphics对象的三种方法。通过示例展示了如何使用Pen、Color、Font和Brush等画图对象绘制基本图形,如渐变矩形。同时,提供了GDI+开发文档的下载链接以供深入学习。
摘要由CSDN通过智能技术生成

    很长一段时间没有更新技术博客了,最近在用C#开发Kinect的程序。所以跟大家分享一下自己一些方面学习和认知。

 

    编写图形程序时需要使用GDI(Graphics Device Interface,图形设备接口),从程序设计的角度看,GDI包括两部分:一部分是GDI对象,另一部分是GDI函数。GDI对象定义了GDI函数使用的工具和环境变量,而GDI函数使用GDI对象绘制各种图形,在C#中,进行图形程序编写时用到的是GDI+(Graphics Device Interface Plus图形设备接口)版本,GDI+是GDI的进一步扩展,它使我们编程更加方便。

 

    C#中的GDI+就相当于java中的Swing控件,是编写图形界面必不可缺的一个接口。GDI+绘图最大的方便得益于C#的可视化编程,所有的控件只需要自己Drag,然后Place,最后Cilck添加监听方法。真的是too young too simple。

 

    绘图的时候要用到Graphics类,所以首先介绍一下Graphics画布

 

    我们首先要创建一个Graphics类实例,这个实例相当于建立了一块画布,有了画布才可以用各种画图方法进行绘图。这个过程其实与java中Swing控件获取画布形式上差不多。

 

    绘图程序的设计过程一般分为两个步骤:(一)创建Graphics对

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、付费专栏及课程。

余额充值