{ This code was written by and donated to the Graphics File Formats } { page by Maris, e-mail: } { ---- } { Martin Reddy, the Graphics File Formats page: } { 8 then begin halt; end; blockread(f1,rgbi,4*aantalkleuren); for p :=1 to aantalkleuren do with rgb[p],rgbi[p] do begin r :=rr shr 2; g :=gg shr 2; b :=bb shr 2; end; set256palette(rgb); with header,beeldinfo do begin if hoogte <= maxy then oudpos :=offset else oudpos :=offset +bytesperlijn *(hoogte -maxy); if breedte < maxx then maxx :=breedte; if hoogte =x2; dec(y); until y<=y1; close(f); end; Procedure GetPal(ColorNo : Byte; Var R,G,B : Byte); { This reads the values of the Red, Green and Blue values of a certain color and returns them to you. } Begin Port[$3C7] := ColorNo; R := Port[$3C8];{You can put in all of numbers $3C8 number $3C9 and then it will get palette with maximum 63 digits each color} G := Port[$3C8]; {I can't find Port, to read color palette} B := Port[$3C8]; {Thats the Port of 8 bit grayscale!} End; {If You know, wich port is the right to read all palette with all its colors, E-Mail me and send this Port number - PLEASE!} procedure save_bmp_8bit(x1,y1,x2,y2:integer; filename:string); var byt1,byt2,rrr,ggg,bbb:byte; f:file of byte; b,b1,b3:byte; w,sakums:word; f2:file of word; bb,bb1,bb2,bbb1,bbb2:string; l:longint; x,y,xx,yy,i,j,col:integer; r,g:byte; begin assign(f2,filename); rewrite(f2); reset(f2); seek(f2,$12 div 2); w:=x2-x1; write(f2,w); seek(f2,$16 div 2); w:=y2-y1; write(f2,w); close(f2); assign(f,filename); reset(f); seek(f,0); b:=0; for i:=1 to $11 do write(f,b); seek(f,$18); for i:=$18 to $76 do write(f,b); seek(f,0); b:=ord('B'); write(f,b); seek(f,1); b:=ord('M'); write(f,b); seek(f,$08); b:=0; write(f,b); write(f,b); seek(f,$0A); b:=$76; write(f,b); seek(f,$0E); b:=$28; write(f,b); seek(f,$1A); b:=$01; write(f,b); seek(f,$1C); b:=16; write(f,b); seek(f,$1C); b:=8; write(f,b); seek(f,$36); b1:=$00; for i:=0 to 255 do begin getpal(i,r,g,b); write(f,b,g,r,b1); end; seek(f,$A); b:=$36; write(f,b); b:=$04; write(f,b); seek(f,$A); read(f,b,b1); asm mov ah,b1 mov al,b mov [sakums],ax {Converts two bytes to one word} end; seek(f,sakums); for y:=y2 downto y1 do for x:=x1+1 to x2 do begin b:=getpixel(x,y); write(f,b); end; close(f); end; begin case bitmap of bit4:save_bmp_4bit(x1,y1,x2,y2,filename); bit8:save_bmp_8bit(x1,y1,x2,y2,filename); end; end; {If You know, wich port is the right to read all palette with all its colors (each color 256 digits of palette), E-Mail me and send this Port number - PLEASE!} {Maybe you know another way how to read current palette? Then E-Mail me! (Maris: e-mail at top of file)} end.