⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 out.c

📁 eCGUI 驱动构造例子 只要驱动例子能运行
💻 C
字号:
#ifndef _GUI_LOW_OUT_C
#define _GUI_LOW_OUT_C

/* #define DEBUG_NODRAW */

#include <dos.h>
#include <graphics.h>
#include "Stdio.h"
#include "stdlib.h"
#include "Conio.h"
#include "dos.h"

int16  dj_gettime(PTIMEINF pt)
{
struct time tm;
gettime(&tm);
pt->hour=tm.ti_hour;
pt->min=tm.ti_min;
pt->sec=tm.ti_sec;
pt->hund=tm.ti_hund;
return 1;
}

int mp_buf[20*20];

uint16 dj_init(struct BITMAP *map)
{
	
  int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
  registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
  initgraph(&gd, &gm, "");
  if(map)
	{
	struct BITMAP *mouse_map;
	map->rect.left=0;
	map->rect.top=0;
	map->rect.right=640;
	map->rect.bottom=480;
	map->color_bit=4;	 
	map->pDraw->mouse_map=(struct BITMAP*)malloc(sizeof(struct BITMAP));
	mouse_map=map->pDraw->mouse_map;
	mouse_map->rect.left=0;
	mouse_map->rect.top=0;
	mouse_map->rect.right=20;
	mouse_map->rect.bottom=20;
	memset(mp_buf,0,20*20*sizeof(int));
	mouse_map->pData=(void*)mp_buf;

	G_COLORS[0]=0;
	G_COLORS[1]=1;
	G_COLORS[2]=2;
	G_COLORS[3]=3;
	G_COLORS[4]=4;
	G_COLORS[5]=5;
	G_COLORS[6]=6;
	G_COLORS[7]=7;
	G_COLORS[8]=8;
    G_COLORS[9]=9;   
	G_COLORS[10]=10;
	G_COLORS[11]=11;
	G_COLORS[12]=12;
	G_COLORS[13]=13;
	G_COLORS[14]=14;
	G_COLORS[15]=15;
	}
}

uint16 dj_exit(struct BITMAP *map)
{
closegraph();
if(map)
	{
	struct BITMAP *mouse_map;
	mouse_map=map->pDraw->mouse_map;
	free(mouse_map);
	}
return True;
}

void   dj_putpixel(struct BITMAP *map,int x,int y,uint32 color)
{
putpixel(x,y,color);

}

uint32 dj_getpixel(struct BITMAP *map,int x,int y)
{
return (uint32)(getpixel(x,y));
}

void   dj_line(struct BITMAP *map,int x1,int y1,int x2,int y2)
{
if(map||x1||x2||y1||y2);
}

void   dj_rectangle(struct BITMAP *map,int x1,int y1,int x2,int y2)
{
if(map||x1||y1||x2||y2);
}


void   dj_bar(struct BITMAP *map,int x1,int y1,int x2,int y2)
{

setfillstyle(SOLID_FILL, map->cur_color); 
bar(x1,y1,x2,y2);
}

void   dj_setcolor(struct BITMAP *map,uint32 color)
{
	 map->cur_color=color;
}

void   dj_setmode(struct BITMAP *map,uint32 mode)
{
	map->cur_mode=mode;
}

void   dj_bitblt(struct BITMAP *dst,int dx,int dy,int width,int height,struct BITMAP *scr,int sx,int sy,int op)
{
int i,j;
char *p;
/* 

  getimage(ulx, uly, lrx, lry, Saucer);
  putimage(ulx, uly, Saucer, XOR_PUT);

*/
if(op==1) /* to Buffer */
	{
	p=(char*)dst->pData;
	#if 0
	for(j=0;j<height;j++)
	 for(i=0;i<width;i++)		 		
	   *(p+j*height+i)=(int)dj_getpixel(scr,sx+i,sy+j);
	#else
	if(sx<0) sx=0;
	if(sy<0) sy=0;
	if(sx+width>639) width=639-sx;
	if(sy+height>479) height=479-sy;
	getimage(sx,sy,sx+width,sy+height,p);
	#endif
	return;
	}
if(op==2) /* to Video */
    {
	p=(char*)scr->pData;
	#if 0
	for(j=0;j<height;j++)
	 for(i=0;i<width;i++)		 		
	   dj_putpixel(dst,dx+i,dy+j,*(p+j*height+i));
	#else
	if(dx<0) dx=0;
	if(dy<0) dy=0;
	putimage(dx,dy,p,COPY_PUT);
	#endif
	return;
	}
}


#endif /* _GUI_LOW_OUT_C */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -