Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to save several TBitmaps into one file Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Aug-02
Category
Files Operation
Language
Delphi 2.x
Views
24
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Does anybody know whether it is possible to write some small TBitmaps with 
different widths and heights into one file?

Answer:

Saving the TBitmap to a Stream, and appending other TBitmaps to that stream, then 
saving the stream to disk would be the method.
1   
2   procedure SaveBitmapToStream(aBitmap: TBitmap; aStream: TStream);
3   var
4     ms: TMemoryStream;
5     size: Integer;
6   begin
7     Assert(Assigned(aBitmap));
8     Assert(Assigned(aStream));
9     ms := TMemoryStream.Create;
10    try
11      aBitmap.SaveToStream(ms);
12      ms.position := 0;
13      size := ms.Size;
14      aStream.WriteBuffer(size, Sizeof(size));
15      aStream.CopyFrom(ms, size);
16    finally
17      ms.free
18    end;
19  end;
20  
21  //then
22  
23  aStream.SaveToFile('FileName');
24  
25  //to read then first off do:
26  
27  aStream.LoadFromFile('FileName');
28  
29  //then
30  
31  procedure LoadBitmapFromStream(aBitmap: TBitmap; aStream: TStream);
32  var
33    ms: TMemoryStream;
34    size: Integer;
35  begin
36    Assert(Assigned(aBitmap));
37    Assert(Assigned(aStream));
38    ms := TMemoryStream.Create;
39    try
40      aStream.ReadBuffer(size, Sizeof(size));
41      ms.CopyFrom(aStream, size);
42      ms.position := 0;
43      aBitmap.LoadfromStream(ms);
44    finally
45      ms.free
46    end;
47  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC