Please download new version:
https://github.com/Xelitan/TIFF-for-Delphi-Lazarus-Free-Pascal/blob/main/TifImage.pasAnd you can set dpi like this:
var T: TTiffImage;
begin
...
T.SetDpi(300);
Explanation of the code posted before:
for y:=0 to Bmp.Height-1 do begin
P := Bmp.Scanline[y];
for x:=0 to Bmp.Width-1 do begin
G := (P^[4*x] + P^[4*x+1] + P^[4*x+2]) div 3;
if G > 127 then G := 1
else G := 0;
P^[4*x ] := G;
end;
end;;
The above code changes image to grayscale by averaging Red, Green and Blue colors.
And then if the resulting gray pixel has value > 127 it makes it white and if not- makes it black.
So this converts picture to black and white only.
for y:=0 to Bmp2.Height-1 do begin
P := Bmp2.Scanline[y];
R := Bmp.Scanline[y];
for x:=0 to Ceil(Bmp2.Width/8)-1 do begin
B := 0;
for i:=0 to 7 do begin
G := R^[4*(8*x+i)];
B := B + (G shl (7-i));
end;
P^[x] := B;
end;
end;
The code above is packing 8 pixels into 1 Byte.