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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - 技术已荒废

c000021a错误 使用托管代码进行 XML Web services 编程 让你的窗口更迷人 动态链接库学习 Delphi调用WebServices(C#)代码 Delphi归来 c#2.0中新增的两个压缩类(转贴) asp.net常用代码 好久不见了 XML(一) 了解WML 接口学习(一) Flash与JavaScript信息交互 字符串替换 在vs2005中如何将Turboc2.0嵌套在网页中? frameset 使用心得 Delphi调用webservice心得 delphi小技巧 序列化使用心得
delphi流操作心得
技术已荒废 · 2006-11-08 · via 博客园 - 技术已荒废

对文件或图片进行流操作,下面是一个示例代码:

 1unit Unit1;
 2
 3interface
 4
 5uses
 6  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 7  Dialogs, StdCtrls, ExtCtrls,types;
 8
 9type
10  TForm1 = class(TForm)
11    Open: TOpenDialog;
12    Button3: TButton;
13    Panel1: TPanel;
14    Image1: TImage;
15    procedure Button3Click(Sender: TObject);
16    procedure Image1Click(Sender: TObject);
17  private
18    { Private declarations }
19  public
20    { Public declarations }
21  end;
22
23var
24  Form1: TForm1;
25 BitmapmemoryStream:TMemoryStream;
26       Bitmap1:TBitmap;
27       bt:TByteDynArray;
28implementation
29
30{$R *.dfm}
31
32procedure TForm1.Image1Click(Sender: TObject);
33   var
34    files:TFileStream;
35      begin
36          BitmapmemoryStream:=TMemoryStream.Create;// file://建立MemoryStream
37         Bitmap1:=TBitmap.Create;
38         if open.Execute then
39         begin
40         files:= TFileStream.Create(open.FileName,fmShareDenyWrite);
41         try
42           Bitmap1.LoadFromStream(files);
43           image1.Picture.Bitmap:=Bitmap1;
44        except
45          ShowMessage('^-^,错了');
46        end;
47      end;
48  end;
49
50procedure TForm1.Button3Click(Sender: TObject);
51var ms:TMemoryStream ;
52begin
53ms:=TMemoryStream.Create;
54if Assigned(Bitmap1) then
55          Bitmap1.SaveToStream(BitmapmemoryStream);
56  if BitmapMemoryStream<>nil then
57        begin
58         try
59          // BitmapmemoryStream.SaveToFile('Bitmap1.txt');  //file://内存流保存,大小与
60           SetLength(bt,BitmapmemoryStream.Size);  //  .InstanceSize
61           BitmapmemoryStream.Read(bt,BitmapmemoryStream.Size);                                              // file://Bitmap1.bmp一样
62           ms.Write(bt,length(bt));
63           ms.SaveToFile('F:\\1.txt');
64         except
65           showmessage('error on access memory!');
66         end;
67     end;
68  end;
69end.
70