{ ICO unit by SQUIRREL }

Unit ico_;

Interface

procedure Draw_ico(sr:string;k,l:integer);

Implementation

USES dos, graph;

CONST WinConv : array[0..15] of byte=(
0,4,2,6,1,5,3,7,8,12,10,14,9,13,11,15);
  ga  : fillpatterntype = (17, 17, 17, $FF, 17, 17, 17, $FF);
  deg : array[0..6] of byte = (0, 1, 9, 11, 15, 15, 15);

procedure Draw_ico(sr:string;k,l:integer);
VAR ico: record
          header : array[0..125] of byte;
          XORtab : array[0..31, 0..15] of byte;
          ANDtab : array[0..31,0..3] of byte;
         end;
 I,J,X,A: byte;
 f      : file;
 grc, grm : integer;
 px, py : integer;
begin
  px := 0{22};
  py := 0{50};

{ WHILE DosError = 0 do} begin
  Assign    ( f, sr );
  Reset     ( f, 1 );
  BlockRead ( f, ico, sizeof(ico) );
  Close     ( f );

  FOR i := 0 to 31 DO
  FOR j := 0 to 31 DO with ICO do BEGIN
    X := Winconv[ XORtab[i, j SHR 1] SHR (4-j AND 1*4) AND 15];
    A :=          ANDtab[i, j SHR 3] SHR (7-j AND 7) AND 1 *15;
    PutPixel(j+ k+px, 31-i + l+py,
    GetPixel(j+ k+px, 31-i + l+py)
    AND A XOR X);
  END;
  inc(k, 80); if (k AND 640)=640 then begin k := 0; inc(l, 64); end;
  if l >= 480 then begin readln; l := 0; end;

 END;
end;

Begin
end.
