如何实现BMP和JPG的互换

解决方案 »

  1.   

    我要满分!!!!function Tpubfunc.Bmp2Jpg(Bmp: TBitmap; Quality: Integer = 100): TJpegImage;
    begin
      Result := nil;
      if Assigned(Bmp)
        then begin
        Result := TJpegImage.Create;
        Result.Assign(Bmp);
        Result.CompressionQuality := Quality;
        Result.JPEGNeeded;
        Result.Compress;
      end;
    end;function Tpubfunc.Jpg2Bmp(Jpg: TJpegImage): TBitmap;
    begin
      Result := nil;
      if Assigned(Jpg)
        then begin
        Result := TBitmap.Create;
        Jpg.DIBNeeded;
        Result.Assign(Jpg);
      end;
    end;