delphi 将memo转化为JPG输出


本文整理自网络,侵删。

 

units1;

interface

uses
  Windows, Messages, SysUtils, Graphics, Controls, Forms, StdCtrls,
  Classes;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
uses jpeg;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  vBitmap: TBitmap;
  vJpegImage: TJpegImage;
  vOldHeight: Integer;
begin
  Canvas.Font.Assign(Memo1.Font);
  vOldHeight := Memo1.Height;
  Memo1.ClientHeight := Canvas.TextHeight('|') * Memo1.Lines.Count + 2;
  vBitmap := TBitmap.Create;
  vJpegImage := TJpegImage.Create;
  try
    vBitmap.Height := Memo1.ClientHeight;
    vBitmap.Width := Memo1.ClientWidth;
    Memo1.PaintTo(vBitmap.Canvas, -2, -2);
    vJpegImage.Assign(vBitmap);
    vJpegImage.CompressionQuality := 75;
    vJpegImage.Compress;
    vJpegImage.SaveToFile('输出.jpg');
      //    Image1.Picture.Graphic   :=   vJpegImage;
  finally
    vBitmap.Free;
    Memo1.Height := vOldHeight;
  end;

end;

相关阅读 >>

Delphi做异型窗体png透明

Delphi console程序中一种定时方法

Delphi:out参数和var参数的区别

cnwizards cnpack ide 专家包

Delphi float转换int

Delphi 计算文件与当前时间差(天小时分钟秒)

Delphi xe system.netencoding 字符串base64编码解码

Delphi判断电脑是否安装了excel

Delphi 利用thttpclient实现http异步下载

Delphi逐个读取access中的数据

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...