function GetBytesFormat(
const AData: TBytes): Integer;
var
signature: TBytes;
begin
Result := -1;
signature := Copy(AData, 0, 8);
if CompareMem(@signature[0], @[$FF, $D8, $FF, $
DB], 4)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$FF, $D8, $FF, $E0, $00, $10, $4A, $46], 8)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$49, $46, $00, $01], 4)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$FF, $D8, $FF, $EE], 4)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$FF, $D8, $FF, $E1], 4)
and CompareMem(@signature[6], @[$45, $78], 2)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$69, $66, $00, $00], 4)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$FF, $D8, $FF, $E0], 4)
then
Result := 0
// JPEG
else
if CompareMem(@signature[0], @[$89, $50, $4E, $47, $0D, $0A, $1A, $0A], 8)
then
Result := 1
// PNG
else
if CompareMem(@signature[0], @[$47, $49, $46, $38, $37, $61], 6)
then
Result := 2
// GIF87a
else
if CompareMem(@signature[0], @[$47, $49, $46, $38, $39, $61], 6)
then
Result := 2
// GIF89a
else
if CompareMem(@signature[0], @[$42, $4D], 2)
then
Result := 3
// BMP
else
if CompareMem(@signature[0], @[$00, $00, $01, $00], 4)
then
Result := 4
// ICO
else
if CompareMem(@signature[0], @[$49, $49, $2A, $00], 4)
then
Result := 5
// TIF
else
if CompareMem(@signature[0], @[$4D, $4D, $00, $2A], 4)
then
Result := 5
// TIFF
;
end;