DPI其实和图片本身没有多大关系,和显示出来的效果有关系
下面设置JPEG 的DPI参数
procedure SetJpgdpi(filename: string; dpix, dpiy: Integer);
const
BufferSize = 50;
DPI = 1; {inch}
DPC = 2; {cm}
var
Buffer: string;
index: Integer;
FileStream: TFileStream;
xResolution: WORD;
yResolution: WORD;
typeA: Byte;
begin
FileStream := TFileStream.Create(filename, fmOpenReadWrite);
try
SetLength(Buffer, BufferSize);
FileStream.Read(buffer[1], BufferSize);
index := Pos('JFIF' + #$00, buffer);
if index > 0 then
begin
FileStream.Seek(index + 6, soFromBeginning);
typeA := DPI;
FileStream.write(typeA, 1);
xresolution := swap(dpix);
FileStream.write(xresolution, 2);
yresolution := swap(dpiy);
FileStream.write(yresolution, 2);
end
finally
FileStream.Free;
end;
end;