2010. augusztus 22., vasárnap
Save a TJEPGImage with DPI information
Problem/Question/Abstract:
I need to save a JPEG with DPI information, but cannot find a PPI or DPI property to set. I know that .JPG headers include horizontal and vertical DPI information, but cannot find a correponding property in Delphi 6's TJPEGImage object. Does anyone know how to do this?
Answer:
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;
type
: 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);
type
:= DPI;
FileStream.write(type, 1);
xresolution := swap(dpix);
FileStream.write(xresolution, 2);
yresolution := swap(dpiy);
FileStream.write(yresolution, 2);
end
finally
FileStream.Free;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése