铁矿厂家
免费服务热线

Free service

hotline

010-00000000
铁矿厂家
热门搜索:
成功案例
当前位置:首页 > 成功案例

DOS真彩色模式下真彩色图像显示技术二柔软剂铸造机兵服纯银触点油漆辅料Frc

发布时间:2023-12-08 10:33:44 阅读: 来源:铁矿厂家

DOS真彩色模式下真彩色图像显示技术(二)

六、示范程序

以上两种编程实现见所附例程,程序在有ISA/VESA/PCI三种总线插槽的 OctekHippo12型主板、AMD DX4/100 CPU、8M RAM、EMC1024×768、28隔行扫描彩色显示器、Cirrus GD5434(2M VRAM)显示卡、Borland C++ 3.1 Small 模式下编译通过。但执行程序并不依赖所编译的硬件环境, 曾经在装有 1M VRAM 的TGUI9440、TGUI9680、ARK2000PV、S3 86C868 等VESA局部总线、PCI局部总线、甚至ISA总线的TVGA8900D(也支持VESA 1.2标准, 1M以下的OEM模式号同TGUI9440)显示卡的486~586各档PC机的DOS环境下均获通过。

示例程序对Super VGA卡VESA BIOS高、真彩色扩展模式编程具有一般性。对本文未提到的其它高、真彩色显示卡,只要其支持VESA标准(Version 1.1),不加修改或稍作修改便可使用;对更高分辨率,只要显示适配卡配2M VRAM, 便可作115H、116H、117H模式的编程, 例程中只要修改highcolor()、truecolor()两函数中n、m的宽高界值和addr的上界。但更重要的是: 程序运行以前用显示适配卡所配调整DRAM像素时钟或调整彩色显示器扫描频率的实用程序, 将像素时钟和扫描频率调整到该卡现行分辨率所要求的值上, 例如, Cirrus GD5434卡(2M VRAM)要在117H模式下顺利仿真显示16.7M真彩色, 须在DOS下先执行 E t640=60 t800=60t1024=60 t1280=0, 程序便可顺利显示高彩色图像。

// 24位PCX高、真彩色图像显示例程

#include stdio.h

#include stdlib.使得回收利用变得可能h

#include dos.h

#include bios.h

#include conio.h

#include io.h

#include mem.h

#include fcntl.h

#include alloc.h

unsigned long dataoffset,Line-bytes;

unsigned long addr;

unsigned int Curpage,Wingran,Y-res,width,height;

FILE *fp;

typedef struct { // PCX图像文件头格式

char manufacture针刺机r;

char version;

char encoding;

char bits-perpixel;

int xmin, ymin;

int xmax, ymax;

int hres;

int vres;

char palette;

char reserved;

char color-planes;

int bytes-perline;

int palettetype;

char filler;

} PCXHEAD;

struct mode infoblock {

unsigned int modeattr;

unsigned char winaattr;

unsigned char winbattr;

unsigned int wingran;

unsigned int winsize;

unsigned int winaseg;

unsigned int winbseg;

unsigned char *pagefunc;

unsigned int bytesperscanline;

unsigned int xres,yres;

unsigned char charx,chary;

unsigned char numberofplanes;

unsigned char bitperpixel;

unsigned char numberofbanks;

unsigned char memorymodel;

unsigned char banksize;

unsigned char numberofimagepages;

unsigned char Reserved;

unsigned char x;

} modeinfo;

void SetVesaMode(unsigned int mode);

void VesaInfo(unsigned int mode);

void map(void);

void Selectpage(unsigned int page);

void highcolor(void);

void truecolor(void);

main() // 主函数

{ PCXHEAD header;

char *filename,c;

printf("Please enter the 640480 24bit RGB mode

PCX fil

ename: ");

gets(filename);

if((fp=fopen(filename, "rb"))==NULL)

{

SetVesaMode(003);

puts("File reading error");

exit(1);

}

fread( (char *) header, 1, sizeof(PCXHEAD), fp);

width = tes-perline;

height = ax - in + 1;

printf("Image information: Width=%d, Height=%d",width,h

eight);

if ((ts-perpixel==8) (lor-planes==3)

) {

printf("

Type : 24bits RGB true colors");

printf("1...Emulating display 16M true color image with

64K high color");

printf("2...Display of 16M true color image");

printf("Press selec 1 or 2 : ");

if ((c=getch())==`1`) {

highcolor();

SetVesaMode(003);

}

else if (c==`2`) {

truecolor();

SetVesaMode(003);

}

else 压滤机{

printf("This is not high-color true-color image !")

;

exit(1);

}

}

fclose(fp);

return 0;

}

// 设置VESA 已拿到国家认可的产品认证证书BIOS扩展模式函数

void SetVesaMode(unsigned int mode)

{ unio REGS r;

unsigned int setmode=1;

=04f02;

=mode;

int86(010, r,

if (!=04f)

setmode=0;

else VesaInfo(mode);

Curpage=0ffff;

return(setmode);

}

// 返回VESA编程信息函数

void VesaInfo(unsigned int mode)

{ unio REGS r;

struct SREGS sr;

=mode;

=04f01;

=FP-SEG( modeinfo);

=FP-OFF( modeinfo);

int86x(010, r, r, sr);

Wingran =ngran;

Line-bytes=tesperscanline;

Y-res

=es;

}

// 计算扫描线始址函数

void map(void)

{ register int i,j;

for(i=0; i Y-res; i++)<锡条/p>

addr =(unsigned long)(i)*Line-bytes;

}

// 选择视频窗口对准页函数

void Selectpage(unsigned int page)

{ unio REGS r;

if (page!=Curpage) {

=0;

=page*64L/Wingran;

=04f05;

int86(010, r,

Curpage=page;

}

}

// 16位高彩色仿真24位PCX真彩色图像显示函数

void highcolor(void)

{ register int i, j;

unsigned int red, green, blue;

unsigned int *word, *wordptr;

int n, m, k, cnt, total;

unsigned long segmet;

unsigned char *pic, *p0,*p1,*p2;

unsigned char page, picdata;

SetVesaMode(0111);

map();

Selectpage(0);

n=min(480,height);

m=min(640,width);

word =(unsigned int *)malloc(2*m);

wordptr=word;

for (k=0; k k++)

pic=(unsigned char *)malloc(m);

p0=pic; p1=pic; p2=pic;

fseek(fp,080L,SEEK-SET);

for(i=0; i i++) {

pic=p0; pic=p1; pic=p2;

word=wordptr;

for (j=0;j j++) {

total = 0;

while(total m) {

cnt = 1;

picdata = fgetc(fp);

if(0c0==(0c0 picdata)) {

cnt = 03f picdata;

picdata = fgetc(fp);

for (k=0; k k++)

*pic++ =picdata;

}

else

*pic++ =picdata;

total+=cnt;

}

}

pic=p0; pic=p1; pic=p2;

for (j=0; j j++) {

red = *pic++ 3;

green= *pic++ 2;

blue = *pic++ 3;

red=red 11; green=green 5;

*word++ =red|green|blue;

}

word=word

ptr;

for (j=0;j 2*(m-1梁平塑料生态产业主动融入全市“6+1”支柱产业);j+=2) {

segmet=addr+j;

page=segmet 16;

if (segmet = 65535L) {

poke(0a000, addr+j, *word++ );

}

else {

Selectpage(page);

poke(0a000, addr+j, *word++ );

}

}

}

getch();

free(wordptr); free(pic);

free(pic) ; free(pic);

}

// 24位PCX真彩色图像全息显示函数

void truecolor(void)

{ register int i, j;

unsigned char *pic, *p0,*p1,*p2;

unsigned char page, picdata;

int n,m,k,cnt,total;

unsigned long segmet;

SetVesaMode(0112);

map();

Selectpage(0);

n=min(480,height);

m=min(640,width);

for (k=0; k k++)

pic=(unsigned char *)malloc(m);

p0=pic; p1=pic; p2=pic;

fseek(fp,080L,SEEK-SET);

for(i=0; i i++) {

pic=p0; pi光隔离器c=p1; pic=p2;

for (j=0;j j++) {

total = 0;

while(total m) {

cnt = 1;

picdata = fgetc(fp);

if(0c0==(0c0 picdata)) {

cnt = 03f picdata;

picdata = fgetc(fp);

for (k=0; k k++)

*pic++ =picdata;

}

else

*pic++ =picdata;

total+=cnt;

}

}

pic=p0; pic=p1; pic=p2;

for (j=0;j 3*(m-1);j+=3) {

segmet=addr+j;

page=segmet 16;

if (segmet = 65535L) {

for (k=0; k k++)

pokeb(0a000, addr+j+k, *pic++);

}

else {

Selectpage(page);

for (k=0; k k++)

pokeb(0a000, addr+j+k, *pic++);

}

}

}

getch();

for (k=0; k k++) free(pic);

}

来源: 计算机论文


金属检测
全自动引伸计
高低温拉力试验机现场
试验机