第九章多媒体编程.ppt
文本预览下载声明
Delphi程序设计教程;第9章 多媒体编程技术 ;第9章 多媒体编程技术
多媒体技术是9 0年代以来计算机技术的一个重要发展方向
,本章将对图形、图像及其他多媒体技术进行剖析,并将介绍使
用Delphi 7 开发多媒体程序的方法和技巧。
9.1 图形、图像对象和组件
Delphi 7中定义了许多图形对象用来支持图形的绘制和显示,同时也提供
了许多的图像组件来支持各种图像的操作
9.1.1 图形对象
1.画布对象
(1)MoveTo(x,y : Integer);
(2)LineTo(x,y : Integer);
(3)Rectangle(X1,y1,x2,y2 : Integer);
(4)Ellips(x1,y1,x2,y2 : Integer);
(5)Textout(X,Y:Integer;const text:string);;2. 画笔对象
画线的方法
(1) Moveto方法,作用是将画笔移到指定位置,使用方法为:moveto(x,y,integer)。
(2) lineto方法,作用是画一条到指定位置的直线段,线段起始位置由画布对象的Penpos属性值即画笔的当前位置确定。使用方法为:lineto(x,y: Integer)。
(3) 画折线的方法,使用方法为Polyline(points:array of TPoint)。
2. 画矩形的方法
3. 画圆或椭圆的方法
4. 画弧形曲线的方法
5. 圆角矩形;3. 画刷对象
画布的画刷(Brush)属性决定图形内部区域的填充方式。
1. 画刷的属性
(1) 颜色属性(Color)。
Canvas.Brash.Color: =〈属性值〉
(2) 风格属性(Style)。
(3) 位图属性。
2. 作图区域
作图区域Rect是Trect属性的对象,同时也是一个函数。Rect对象的作用就是定义一个矩形区域对象。Rect对象用两个Tpoint类型或用四个整形变量指明区域范围。;下面举例说明各个对象的应用。
【例9-1】综合利用画笔,画刷
以及画布对象的例子。要求可
以绘制至少三种图形,并可以
改变画笔,画刷的颜色以及风格。
(1)界面设计
(2) 属性设置
procedure TForm1.FormShow(Sender: TObject);
begin
comb_graph.Clear; //显示绘制图形组合框清空
comb_graph.Items.Add(矩形); //添加项目
comb_graph.Items.Add(‘椭圆’);
comb_graph.Items.Add(多边形);
comb_pencolor.clear;
comb_pencolor.Items.Add(‘clred’); //画笔颜色选择组合框添加项目
comb_pencolor.Items.Add(clbalck);
comb_pencolor.Items.Add(clgreen);
comb_pencolor.Items.Add(clblue);
comb_pencolor.Items.Add(clyellow);
comb_brushcolor.clear;
comb_brushcolor.Items.Add(clred); //画刷颜色选择组合框添加项目
comb_brushcolor.Items.Add(clbalck);
comb_brushcolor.Items.Add(clgreen); ; comb_brushcolor.Items.Add(clblue);
comb_brushcolor.Items.Add(clyellow);
comb_penstyle.clear;
comb_penstyle.Items.Add(pssolid); //画笔风格选择组合框添加项目
comb_penstyle.Items.Add(psdash);comb_penstyle.Items.Add(psdot);
comb_penstyle.Items.Add(psdashdot);
comb_brushstyle.clear;
comb_brushstyle.Items.Add(bssolid); //画刷风格选择组合框添加项目
comb_brushstyle.Items.Add(bsClear);
comb_brushstyle.Items.Add(bshorizontal);
comb_brus
显示全部