zoukankan      html  css  js  c++  java
  • 将memo转化为JPG输出,使用Memo1.PaintTo(Bitmap.Canvas)

    unit unit1;

    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;

    http://www.cnblogs.com/wxy8/archive/2011/01/13/1934477.html

  • 相关阅读:
    主线程到子线程的相互切换
    IOS通过OTA部署App
    IOS应用之间调用
    静态库详解
    ObjectC的函数调用机制详解消息
    iOS6新特征:参考资料和示例汇总
    杭电acm2025
    杭电acm2051
    杭电acm1009
    杭电acm2099
  • 原文地址:https://www.cnblogs.com/findumars/p/8207058.html
Copyright © 2011-2022 走看看