画图软件C程序代码

画图软件C程序代码
画图软件C程序代码

#include

#include

#include

#include

#include

#include

#include

#include

/*定义常量*/

/*向上翻页移键*/

#define PAGEUP 0x4900

/*向下翻页移键*/

#define PAGEDOWN 0x5100

/*Escape键*/

#define ESC 0x011b

/*左移键*/

#define LEFT 0x4b00

/*右移键*/

#define RIGHT 0x4d00

/*下移键*/

#define DOWN 0x5000

/*上移键*/

#define UP 0x4800

/*空格键*/

#define SPACE 0x3920

#define NO_PRESSED 0

#define LEFT_PRESSED 1

#define RIGHT_PRESSED 2

#define pi 3.1415926

/*定义全局变量*/

int Rx,Ry,R;

int TOPx,TOPy,BOTTOMx,BOTTOMy;

int Centx,Centy;

int lineStartx,lineStarty,lineEndx,lineEndy;

int linePoint_x[20],linePoint_y[20];

/*这里的字模数组均由“点阵字模工具”生成,你可以用你自己需要的点阵信息来替换示例中的字模信息,注意字模大小要一致,否则显示会出问题。*/

char zhi16K[]={

/* 以下是 '直' 的 16点阵楷体_GB2312 字模,32 byte */

0x01,0x00,0x01,0x00,0x01,0xF0,0x1E,0x00,

0x02,0x00,0x07,0xC0,0x08,0x40,0x0F,0x40,

0x08,0x40,0x0F,0x40,0x08,0x40,0x0F,0x40,

0x08,0x40,0x0F,0xFC,0x70,0x00,0x00,0x00,

};

char xian16K[]={

/* 以下是 '线' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x80,0x00,0x90,0x08,0x88,0x10,0x80,

0x24,0xF0,0x45,0x80,0x78,0xB0,0x11,0xC0,

0x2C,0x88,0x70,0x50,0x04,0x60,0x18,0xA4,

0x63,0x14,0x00,0x0C,0x00,0x04,0x00,0x00,

};

char ju16K[]={

/* 以下是 '矩' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x00,0x08,0x00,0x08,0x78,0x10,0x80,

0x1E,0x80,0x28,0xF8,0x48,0x88,0x0E,0x88,

0xF8,0xF0,0x08,0x80,0x14,0x80,0x12,0x9E,

0x20,0xE0,0x40,0x00,0x00,0x00,0x00,0x00,

};

char xing16K[]={

/* 以下是 '形' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x00,0x07,0x88,0x3A,0x08,0x12,0x10,

0x12,0x20,0x17,0x48,0xFA,0x10,0x12,0x20,

0x12,0xC8,0x12,0x08,0x22,0x10,0x42,0x20,

0x00,0x40,0x00,0x80,0x03,0x00,0x00,0x00,

};

char yuan16K[]={

/* 以下是 '圆' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0xF8,0x3F,0x08,0x23,0x88,0x24,0x88,

0x27,0x08,0x21,0xC8,0x2E,0x48,0x29,0x48,

0x29,0x48,0x22,0x88,0x24,0x48,0x28,0x08,

0x3F,0xE8,0x00,0x10,0x00,0x00,0x00,0x00,

};

char qing16K[]={

/* 以下是 '清' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x80,0x00,0xE0,0x33,0x80,0x10,0xE0,

0x03,0x80,0x40,0xFC,0x2F,0x00,0x01,0xE0,

0x12,0x20,0x13,0xA0,0x22,0x20,0x63,0xA0,

0x42,0x20,0x02,0x60,0x00,0x20,0x00,0x00,

};

char ping16K[]={

/* 以下是 '屏' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0xF0,0x0F,0x30,0x08,0x60,0x0F,0x80,

0x0A,0x20,0x09,0x40,0x08,0xF8,0x17,0x20,

0x11,0x3E,0x2F,0xE0,0x21,0x20,0x42,0x20,

0x82,0x20,0x04,0x20,0x08,0x20,0x00,0x00,

};

char bao16K[]={

/* 以下是 '保' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x00,0x09,0xF0,0x0A,0x10,0x12,0x10,

0x13,0xE0,0x30,0x80,0x50,0xFC,0x9F,0x80,

0x11,0xC0,0x12,0xA0,0x14,0x98,0x18,0x8E,

0x10,0x80,0x10,0x80,0x00,0x00,0x00,0x00,

};

char cun16K[]={

/* 以下是 '存' 的 16点阵楷体_GB2312 字模,32 byte */ 0x01,0x00,0x01,0x00,0x01,0xF0,0x1E,0x00,

0x02,0x70,0x05,0x90,0x08,0x20,0x08,0x40,

0x18,0x7E,0x2B,0xA0,0xC8,0x20,0x08,0x20,

0x08,0x20,0x08,0xA0,0x00,0x40,0x00,0x00,

};

char jia16K[]={

/* 以下是 '加' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,

0x0F,0x00,0x79,0x3C,0x09,0x44,0x11,0x44,

0x11,0x44,0x22,0x44,0x22,0x78,0x4A,0x00,

0x84,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

char zai16K[]={

/* 以下是 '载' 的 16点阵楷体_GB2312 字模,32 byte */ 0x00,0x80,0x08,0xA0,0x08,0x90,0x0E,0x80,

0x38,0xF0,0x0F,0x80,0x78,0x50,0x0E,0x50,

0x34,0x20,0x1E,0x20,0x34,0x50,0x0E,0x92,

0x75,0x0A,0x04,0x06,0x04,0x02,0x00,0x00,

};

char bang16K[]={

/* 以下是 '帮' 的 16点阵楷体_GB2312 字模,32 byte */

0x04,0x00,0x07,0x38,0x1C,0x48,0x06,0x50,

0x1C,0x50,0x07,0x48,0x78,0x58,0x11,0x40,

0x21,0xF0,0x4F,0x10,0x09,0x10,0x09,0x50,

0x09,0x20,0x01,0x00,0x01,0x00,0x00,0x00,

};

char zhu16K[]={

/* 以下是 '助' 的 16点阵楷体_GB2312 字模,32 byte */

0x00,0x00,0x00,0x20,0x0C,0x20,0x34,0x20,

0x24,0x20,0x34,0x38,0x25,0xC8,0x34,0x48,

0x24,0x48,0x26,0x88,0x38,0x88,0xE1,0x28,

0x02,0x10,0x04,0x00,0x00,0x00,0x00,0x00,

};

/*自定义函数*/

void outChinese(char *mat,int matsize,int x,int y,int color); void fill(int startx,int starty,int endx,int endy,int color); void showHelp();

void save();

void load();

int mouseStatus(int* x,int* y);

int setMousePos(int x, int y);

void DrawMouse(float x,float y);

void DrawLine();

void DrawRectangle();

void LineToCircle(int x0,int y0,int r);

void DrawCircle();

long factorial(int n);

float berFunction(int i,int n,double t);

void DrawBezier();

/*根据点阵信息显示中文函数*/

void outChinese(char *mat,int matsize,int x,int y,int color) /*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/

{

int i, j, k, n;

n = (matsize - 1) / 8 + 1;

for(j = 0; j < matsize; j++)

for(i = 0; i < n; i++)

for(k = 0;k < 8; k++)

if(mat[j * n + i] & (0x80 >> k))

/*测试为1的位则显示*/

putpixel(x + i * 8 + k, y + j, color);

}

/*填充函数*/

void fill(int startx,int starty,int endx,int endy,int color)

{

int i,j;

for(i=startx;i<=endx;i++)

for(j=starty;j<=endy;j++)

/*在指定位置以指定颜色画一像素*/

putpixel(i,j,color);

}

/*显示用户帮助函数*/

void showHelp()

{

setcolor(14);

outtextxy(45,50,"Line:");

setcolor(WHITE);

outtextxy(45,50," 1 Press left button to start until to line end.");

outtextxy(45,65," 2 Use UP,DOWN,LEFT,RIGHT keys to move it.");

outtextxy(45,80," 3 Use PAGEUP key to enlarge it, and PAGEDOWN key to shrink it.");

outtextxy(45,95," 4 Use SPACE key to rotate it.");

setcolor(14);

outtextxy(45,120,"Rectangle:");

setcolor(WHITE);

outtextxy(45,120," 1 Press left button to start until to right corner.");

outtextxy(45,135," 2 Use UP,DOWN,LEFT,RIGHT keys to move it.");

outtextxy(45,150," 3 Use PAGEUP key to enlarge it, and PAGEDOWN key to shrink it.");

setcolor(14);

outtextxy(45,170,"Circle:");

setcolor(WHITE);

outtextxy(45,170," 1 Press left button to start until to end.");

outtextxy(45,185," 2 Use PAGEUP key to enlarge it, and PAGEDOWN key to

相关主题
相关文档
最新文档