procedureTForm1.BitBtn4Click(Sender:TObject);
var
MyImage:TMemoryStream;
Buffer:Word;
i:integer;
begin
ifOpenDialog1.Executethen
begin
MyImage:=TMemoryStream.Create;
MyImage.LoadFromFile(OpenDialog1.FileName);
MyImage.Position:=0;
ifMyImage.Size=0then
begin
//ERR
ShowMessage('ERR');
MyImage.Free;
Exit;
end;
MyImage.ReadBuffer(Buffer,2);
ifBuffer=$4D42then
begin
//BMP
ShowMessage('BMP');
end
elseifBuffer=$D8FFthen
begin
//JPEG
ShowMessage('JPEG');
end
elseifBuffer=$4947then
begin
//GIF
ShowMessage('GIF');
end
elseifBuffer=$050Athen
begin
//PCX
ShowMessage('PCX');
end
elseifBuffer=$5089then
begin
//PNG
ShowMessage('PNG');
end
elseifBuffer=$4238then
begin
//PSD
ShowMessage('PSD');
end
elseifBuffer=$A659then
begin
//RAS
ShowMessage('RAS');
end
elseifBuffer=$DA01then
begin
//SGI
ShowMessage('SGI');
end
elseifBuffer=$4949then
begin
//TIFF
ShowMessage('TIFF');
end
else
begin
//ERR
ShowMessage('ERR');
end;
MyImage.Free;
end;
end;
文章转载自『幽月's Blog』地址: http://a1l.cn/article.asp?id=12912