delphi 图像文件加载到剪切板,再从剪切板绘制图像


本文整理自网络,侵删。

 
描述
下面的代码在按下按钮时从剪贴板绘制位图图像。要将图标放置在剪贴板上,必须在LoadFromClipboard按钮之前选择SaveToClipboard按钮。

uses Clipbrd;

procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap : TBitmap;
  s : string;
  Icon: TIcon;
begin
 Bitmap := TBitMap.Create;
 try
   Image1.Picture.RegisterClipboardFormat(cf_BitMap,TIcon);
   Bitmap.LoadFromClipBoardFormat(
     cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
   Canvas.draw(0,0,Bitmap);
 finally
   Bitmap.free;
   Clipboard.Clear;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  MyFormat : Word;
  Bitmap : TBitMap;
  AData : THandle;
  APalette : HPALETTE;
begin
  Bitmap := TBitmap.Create;
  try
    Bitmap.LoadFromFile('c:\Program Files\Common Files\CodeGear Shared\Images\Splash\256color\factory.bmp');
    Bitmap.SaveToClipBoardFormat(
      MyFormat,
      AData,
      APalette);
    ClipBoard.SetAsHandle(MyFormat,AData);
  finally
    Bitmap.Free;
  end;
end;

相关阅读 >>

Delphi android 程序名称在哪里设置?

用tidftp控件实现ftp协议

Delphi在目录中搜索文件

Delphi windows api判断文件共享锁定状态

Delphi文本文件读写

Delphi memo1 行随机打乱

Delphi opendialog1 打开多个文件

Delphi ansi字符串转unicode编码

Delphi 如何确定access数据库中存在某一个已知名的表

isleapyear:返回给定的年份是否是闰年

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



打赏

取消

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

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

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

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

评论

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