zoukankan      html  css  js  c++  java
  • 将bmp文件转换为jpg文件

    procedure TForm1.Button1Click(Sender: TObject);
    (*压缩MBP为JPEG;但是没有提供压缩比可选项
    凑合用吧,大概1/3 ^_^:
    Note:必须加上JPEG到Uses单元
    *)
    var
    MyJPEG : TJPEGImage;
    MyBMP : TBitmap;
    begin
    MyBMP := TBitmap.Create;
    with MyBMP do
    try
    LoadFromFile('e:lm.BMP'); //你的图片位置
    MyJPEG := TJPEGImage.Create;
    with MyJPEG do begin
    Assign(MyBMP);
    CompressionQuality:=10; //压缩比例
    Compress;
    SaveToFile('e:lm01.JPEG');//保存路径……
    Free;
    end;
    finally
    Free;
    end;
    end;


    By Luiz Vaz - luiz.vaz@arinso.com.br

    function Bmp2Jpg(Bmp: TBitmap; Quality: Integer = 100): TJpegImage;

    begin

      Result := nil;

      if Assigned(Bmp)

      then begin

      Result := TJpegImage.Create;

      Result.Assign(Bmp); {Its all folks...}

      Result.CompressionQuality := Quality;

      Result.JPEGNeeded; {Key method...}

      Result.Compress;

      end;

    end;

    function Jpg2Bmp(Jpg: TJpegImage): TBitmap;

    begin

      Result := nil;

      if Assigned(Jpg)

      then begin

      Result := TBitmap.Create;

      Jpg.DIBNeeded; {Key method...}

      Result.Assign(Jpg); {Its all folks...}

      end;

    end;

    注意:JPEGNeeded过程转换并存储图像数据到内部的JPEG数据。我们无法直接存取JPEG 内部数据,因为D5并没有提供jpeg.pas单元的源码。但是可以通过JPEGNeeded和DIBNeeded过程来操作它。

  • 相关阅读:
    【经典】仙岛求药(一)
    6月份学习记录
    YZM的全排列
    最长公共子序列的长度
    20612统计八连块
    积木城堡
    不同组合数求和
    50136142WXY的百度地图
    50095106扔核弹
    【其他】关于海岛帝国互测系列赛总结
  • 原文地址:https://www.cnblogs.com/yzryc/p/6373609.html
Copyright © 2011-2022 走看看