惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Palo Alto Networks Blog
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
C
Cisco Blogs
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Know Your Adversary
Know Your Adversary
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
D
Darknet – Hacking Tools, Hacker News & Cyber Security
W
WeLiveSecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
I
Intezer
GbyAI
GbyAI
Jina AI
Jina AI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Google Online Security Blog
Google Online Security Blog
Engineering at Meta
Engineering at Meta
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
小众软件
小众软件
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
Project Zero
Project Zero

博客园 - 涂磊

02]AdvStringGrid中添加CheckBox 01]TMSadvStringGrid下载与安装 epson投影仪提示,保存时间的电池电量偏低,取消显示 用DeepSeek做的Delphi闹钟 XboxS联网下载完游戏后,要拔掉网线,就能玩游戏了 12]RichEdit某些文本突出显示 delphi10.3中Tmemo中某些文本显示下划线 delphi的TReeView支持鼠标拖动节点 cnPack里MarkDown里RTF显示 11]delphi中 RichEdit1设置行距 10]RichEdit另存 为BMP图片 09]delphi中richedit查找 07]Delphi10.3中Richedit中的链接可以点击 06]delphi10.3中richedit中文本背景颜色 05]delphi10.3中richedit中删除线 delphi10.3中UpDown1使用 04]RichEdit的上标和下标,Delphi10.3 03]RichEdit插入BMP图片 delphi 中tButtonColor颜色选择 02]如何设置RichEdit文本颜色?_编程语言-CSDN问答 01]delphi从TRichEdit获得RTF格式文本(PC版本) Delphi10.3接收从文件管理器拖放过来的文件名
08]delphi10.3剪贴板的图片,保存到文件
涂磊 · 2026-02-17 · via 博客园 - 涂磊
uses
  Classes, SysUtils, Clipbrd, Graphics,PNGImage, JPEG;
type
  TClipboardImageFormat = (cfBMP, cfPNG, cfJPEG);

procedure SaveClipboardImageToFile(const FileName: string; 
  Format: TClipboardImageFormat = cfBMP; 
  JPEGQuality: Integer = 90);
function ClipboardHasImage: Boolean;

implementation

uses
  PNGImage, JPEG;

function ClipboardHasImage: Boolean;
begin
  Result := Clipboard.HasFormat(CF_BITMAP) or 
            Clipboard.HasFormat(CF_PICTURE) or
            Clipboard.HasFormat(CF_METAFILEPICT);
end;

procedure SaveClipboardImageToFile(const FileName: string; 
  Format: TClipboardImageFormat; 
  JPEGQuality: Integer);
var
  Bitmap: TBitmap;
  PNG: TPNGImage;
  JPEG: TJPEGImage;
begin
  if not ClipboardHasImage then
    raise Exception.Create('剪贴板中没有图片');
    
  Bitmap := TBitmap.Create;
  try
    Bitmap.Assign(Clipboard);
    
    case Format of
      cfPNG:
        begin
          PNG := TPNGImage.Create;
          try
            PNG.Assign(Bitmap);
            PNG.SaveToFile(FileName);
          finally
            PNG.Free;
          end;
        end;
      cfJPEG:
        begin
          JPEG := TJPEGImage.Create;
          try
            JPEG.Assign(Bitmap);
            JPEG.CompressionQuality := JPEGQuality;
            JPEG.SaveToFile(FileName);
          finally
            JPEG.Free;
          end;
        end;
    else // cfBMP
      Bitmap.SaveToFile(FileName);
    end;
  finally
    Bitmap.Free;
  end;
end;
procedure TMainForm.EditPaste(Sender: TObject);
var
  ClipboardText, BMPdir: string;
begin
  ClipboardText := Clipboard.AsText;
  if ClipboardHasImage then   begin
//     BMPdir:=                         // 保存为BMP
    BMPdir:=  ExtractFilePath(ParamStr(0))  +   'image.bmp'   ;

    SaveClipboardImageToFile(BMPdir,cfBMP, 95);
     if FileExists(BMPdir) then
      RichEx.InsertBitmap(editor.Handle,BMPdir)
  end else begin
    editor.SelText:=  ClipboardText;
  end;
end;
 // 保存为BMP
SaveClipboardImageToFile('C:\image.bmp',cfBMP, 95);

// 保存为PNG
//SaveClipboardImageToFile('C:\image.png', cfPNG, 95);
//
//// 保存为JPEG(设置质量)
//SaveClipboardImageToFile('C:\image.jpg', cfJPEG, 95);

image