文件偏移怎么计算
#include<process.h>#include<stdio.h>
#include<graphics.h>
#include<conio.h>
void saveall(char *filename)
{ FILE *fp;
unsigned long size=imagesize(0,0,639,120);
unsigned long save_1;
int save_i;
char *buffer;
fp=fopen(filename,"wb");
buffer=(char *)malloc(size);
for(save_i=0;save_i<4;save_i++)
{ save_1=38726L*save_i;
fseek(fp,save_1,SEEK_SET);
getimage(0,120*save_i,639,120*(save_i+1),buffer);
fwrite(buffer,size,1,fp);
}
free(buffer);
fclose(fp);
}
void loadall(char *filename)
{ FILE *fp;
unsigned long size=imagesize(0,0,639,120);
unsigned long load_1;
int load_i;
char *buffer;
if((fp=fopen(filename,"rb"))==NULL)
{ setcolor(12);
outtextxy(100,100,"<file not open !>");
fclose(fp);
return;
}
buffer=(char *)malloc(size);
for(load_i=0;load_i<4;load_i++)
{ load_1=38726L*load_i;
fseek(fp,load_1,SEEK_SET);
fread(buffer,size,1,fp);
putimage(0,120*load_i,buffer,COPY_PUT);
}
free(buffer);
fclose(fp);
}
void main()
{ int driver=DETECT,mode=0,i;
initgraph(&driver,&mode,"");
randomize();
for(i=0;i<100;i++)
{ setcolor(rand()%16);
circle(rand()%getmaxx(),rand()%getmaxy(),rand()%10);
}
saveall("screen.dat");
getch();
cleardevice();
getch();
loadall("screen,dat");
getch();
closegraph();
}
这是一个分四次显示屏幕的程序在保存和显示时都有一个文件偏移的计算save_1=38726L*save_i;和load_1=38726L*load_i; 这个38726是怎么计算出来的?帮忙解答一下.
[此贴子已经被作者于2006-8-9 22:12:56编辑过]