у меня есть исходник на ЦПП и на паскале (только для чтения 256 цвеиных изображений) только для них нужен svga256.bgi {C++} #include #include #include #include #include #define buflen 1024 char buff[buflen]; int myfgetc(int h) { _read(h, buff, buflen); return 0; } int main(void) { int gd,gm,x,y, j, i, offs; int maxx,maxy; char ch,R,G,B,RES; gd = installuserdriver("svga256", NULL); gm = 3; initgraph(&gd,&gm,""); // CLEAR PALETTE for (i=0;i<256;i++){ outp(0x3c8,i); outp(0x3c9,0); outp(0x3c9,0); outp(0x3c9,0); } int hfile; // OPEN IMAGE hfile = _open("bbb.bmp", O_RDONLY|O_BINARY); if (hfile==-1) { closegraph(); printf("Error opening file !!!"); return (0); } lseek(hfile, 0, SEEK_SET); _read(hfile, buff, buflen); // LOAD IMAGE PAREMETERS if ( *((int*)(buff)) !=19778) { closegraph(); printf("This is not bitmap image"); return 0; } offs = *((int*)(buff+10)); maxx = *((int*)(buff+18)); maxy = *((int*)(buff+22)); // OUTPUT IMAGE lseek(hfile, offs, SEEK_SET); _read(hfile, buff, buflen); i = 0; for (y=maxy; y>0; y--) { for (x=0; x { putpixel(x, y, buff[i]); if (++i ==buflen) {myfgetc(hfile); i = 0;} } } lseek(hfile, 54, SEEK_SET); _read(hfile, buff, buflen); i = 0; // CHANGE PALETTE for (j=0;j<256;j++){ outp(0x3c8,j); B = buff[i++]; G = buff[i++]; R = buff[i++]; i++; outp(0x3c9,R>>2); outp(0x3c9,G>>2); outp(0x3c9,B>>2); } // FLUSH KEYBOARD BUFFER asm{ mov ax,0x0C00 int 0x21 } // WAIT FOR ANY KEY PRESSED getch(); closegraph(); return (0); } {Pascal} uses graph; var gd,gm,x,y,maxx,maxy,sob:integer; f1:file of integer; f2:file of byte; buff,r,g,b,res:byte; begin gd:=installuserdriver('svga256',nil); gm:=0; initgraph(gd,gm,''); for y:=1 to 256 do begin port[$3C8]:=y-1; port[$3C9]:=0; port[$3C9]:=0; port[$3C9]:=0; end; assign(f1,ParamStr(1)); reset(f1); seek(f1,5); read(f1,sob); seek(f1,9); read(f1,maxx); seek(f1,11); read(f1,maxy); close(f1); assign(f2,ParamStr(1)); reset(f2); seek(f2,sob); for y:=0 to maxy-1 do for x:=0 to maxx-1 do begin read(f2,buff); putpixel(x,maxy-y,buff) end; seek(f2,54); for y:=1 to 256 do begin read(f2,b); read(f2,g); read(f2,r); read(f2,res); port[$3C8]:=y-1; r:= r shr 2; g:= g shr 2; b:= b shr 2; port[$3C9]:=r; port[$3C9]:=g; port[$3C9]:=b; end; close(f2); asm mov ah,0 int 16h end; closegraph; end.
Ответить
|