请问如何判断image1中的文件是BMP还是JPG?(0分)

  • 主题发起人 主题发起人 redphoenix
  • 开始时间 开始时间
R

redphoenix

Unregistered / Unconfirmed
GUEST, unregistred user!
不通过判断后缀的方式还有其他什么方法吗?
 
将文件用流的形式读出来,根据文件头进行判断。
BMP的文件开始两个字节好象是BM吧
你找资料看看
 
其实我是不知道怎么把JPG文件进行旋转,才想把JPG文件先转换为BMP文件再进行旋转的,但是就是不知道如何才能判断IMAGE中的文件是JPG还是BMP,所以才问的这个问题。
如果能解决JPG旋转问题,就不用转换了,JPG文件不转换怎么旋转呢??
 
一个旋转算法:
const
rotation = 2/3*pi;
var
x,y : integer;
newx,newy : integer;
radius,a : real;
begin
for x:=1 to image1.Picture.Width do
begin
for y:=1 to image1.Height do
begin
radius:=Sqrt(Sqr(X)+Sqr(Y));
a:=Arctan(Y/X);
newx:=round(Radius*Cos(A+Rotation)+300);
newy:=round(Radius*Sin(A+Rotation)+300);
image2.Canvas.Pixels[newx,newy]:=image1.Canvas.Pixels[x,y];
end;
end;
end;
注:image1是原图
image2是旋转后的图
 
image2.Canvas.Pixels[newx,newy]:=image1.Canvas.Pixels[x,y];
只能对位图进行!
 
存入文件流 判断文件头前4个字节
 
BMP:=iamge1.picture.bmp.emperty=true;
 
接受答案了.
 
后退
顶部