| DOS界面下通用图形编辑软件的设计
| | 中学计算机教育论文摘 要 该文介绍了一种建立在dos界面下生成图素文件的中学计算机教育论文通用图形编辑程序的中学计算机教育论文设计方法。 目前用作ddc的pc总线工控机(ipc)大部分工作在dos界面上,而dos不具有像windows那样美观方便的图形用户接口(gui)。生成工艺流程图等复杂图形若用程序设计语言直接编程需花费大量精力和代码,且不易修改。设计出数据文件小,占用内存少的图形编辑软件是控制界的一个研究课题。这里介绍一种生成图素数据文件的通用图形编辑软件的设计方法。 一、数据结构与数据文件格式 由于所有的操作都基本建立在图素的基础之上,故数据结构也以图素为中心。以下以圆、直线、矩形、字符串为例,其它图素类似。 1.定义所需图素 struct circle /*定义圆 */ { int x,y,r; /* 圆心,半径 */ char linecolor,linestyle; /* 圆外围线的颜色,线型 */ char fillcolor,fillstyle; /* 填充颜色,模式 */ }; struct line /* 定义直线 */ { int x1,y1; int x2,y2; char linecolor,linestyle,linethick; /* 线颜色,模式,粗细 */ }; struct box /* 定义矩形 */ { int x1,y1; int x2,y2; char linecolor,linestyle; char fillcolor,fillstyle; }; struct string /* 定义字符串 */ { int x,y; char str[10] char backcolor,dir; char str-color,str-style; }; . . /* 定义其它图素 */ . 2.将各图素置于一条链表之中 typedef struct tagelementlist { char elementtype; /* 标识元素类别 */ int elementid; /* 元素标识符,在接口中用来控制其属性 */ union tagelement { struct circle circle; struct box box; struct string string; struct line line; . . /* 可在此说明其它元素 */ . }element; struct tagelementlist *next; }elementlist; 利用这种数据结构可在内存中形成一个图素链表,所有操作都可以此链表为基础。 3.定义几个指针,以备各种操作 elementlist *list-head. *list-end,*list-temp, *list-here; 4.定义一个全局变量,记录图素个数 static int elementcount=0; 图形文件格式为:第一字节(char),表示整个图形的背景颜色;接下来一个字(word),对应于elementcount,表示图素个数;后面是内存链表中每个图素的属性值。 二、图形编辑功能的实现 本软件包含的图形编辑功能主要有:作图、修改、移动、删除、复制,下面仅举几例说明实现的方法。 1.作图 以圆为例,其它图形类似。
| | | |
|