问题如题,用文件后缀的方法不行,还有其他什么方法吗?

解决方案 »

  1.   

    我一直就是用判断后缀的方法,我猜你可能是想如果是BMP就对它作出修改吧,你可以多加一条判断语句如果是JPG就吧他改成BMP在装载到IMAGE中
      

  2.   

    给点思路你
    function Tform1.JpgToBmp(Jpg: TJpegImage): TBitmap;
    begin
      Result := nil;
      if Assigned(Jpg) then
      begin
        Result := TBitmap.Create;
        Jpg.DIBNeeded;
        Result.Assign(Jpg);
      end;
    end;
      

  3.   

    其实我是不知道怎么旋转JPG文件才想出来把JPG先转换成BMP文件再进行旋转
    但是我真的不知道该怎么判断掉入IMAGE中的文件是什么类型的,后缀名的方式在我的这个程序中不行
    请问JPG文件可以直接进行旋转处理吗?
      

  4.   

    var
      FStream:TStream;
      Buffer:Word;FStream:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyWrite);
    FStream.ReadBuffer(Buffer,2);
    FStream.Position:=0;
    if Buffer=$4D42 then
    begin
      //BMP
    end
    else if Buffer=$D8FF then
    begin
      //JPEG
    end
    else if Buffer=$4947 then
    begin
      //GIF
    end
    else if Buffer=$050A then
    begin
      //PCX
    end
    else if Buffer=$5089 then
    begin
      //PNG
    end
    else if Buffer=$4238 then
    begin
      //PSD
    end
    else if Buffer=$A659 then
    begin
      //RAS
    end
    else if Buffer=$DA01 then
    begin
      //SGI
    end
    else if Buffer=$4949 then
    begin
      //TIFF
    end
    else
      ...