Solved

Putting Bitmap data into a "pas" file...

Posted on 1998-10-25
2
282 Views
Last Modified: 2010-04-06
How can I store some bitmaps in my "pas" unit without creating a "res" file? I've a quite big utility unit which just needs 2 or 3 bitmaps. And I would really like to save this "res" file.
A little example would be great. Can I perhaps somehow copy the bitmap data from the "View form as text" option?

Thanx, Madshi.
0
Comment
Question by:Madshi
2 Comments
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1344293
Hi friend,
Here is how to do what you want, simply paste it to your implementation section, put a button on form and link Button1Click with the code. Regarding converting file data to pascal I use the Hex Workshop which is a commercial hex file editor. It can convert the selected block to a comma delimited array. But the programmer on your level has no trouble to write such a conversion routine. The bitData contains the all binary data from the C:\Program Files\Borland\Delphi 3\Images\ICONS\CHEM16.BMP.

implementation

{$R *.DFM}

const
 bitData : array[0..247] of byte = (
$42, $4D, $F8, $00, $00, $00, $00, $00, $00, $00, $76, $00, $00, $00, $28, $00,
$00, $00, $10, $00, $00, $00, $10, $00, $00, $00, $01, $00, $04, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $12, $0B, $00, $00, $12, $0B, $00, $00, $00, $00,
$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $00, $00, $80,
$00, $00, $00, $80, $80, $00, $80, $00, $00, $00, $80, $00, $80, $00, $80, $80,
$00, $00, $7F, $7F, $7F, $00, $BF, $BF, $BF, $00, $00, $00, $FF, $00, $00, $FF,
$00, $00, $00, $FF, $FF, $00, $FF, $00, $00, $00, $FF, $00, $FF, $00, $FF, $FF,
$00, $00, $FF, $FF, $FF, $00, $55, $55, $55, $00, $05, $55, $55, $55, $55, $55,
$00, $88, $80, $05, $55, $55, $55, $50, $88, $CC, $C8, $80, $55, $55, $55, $50,
$8C, $88, $8C, $80, $55, $55, $55, $08, $CC, $CC, $CC, $C8, $05, $55, $55, $08,
$CE, $CC, $CC, $C8, $05, $55, $55, $08, $CE, $EC, $CC, $C8, $05, $55, $55, $50,
$8C, $44, $4C, $80, $55, $55, $55, $50, $88, $FF, $F8, $80, $55, $55, $55, $55,
$08, $FF, $F8, $05, $55, $55, $55, $55, $50, $8F, $80, $55, $55, $55, $55, $55,
$50, $8F, $80, $55, $55, $55, $55, $55, $50, $8F, $80, $55, $55, $55, $55, $55,
$50, $8F, $80, $55, $55, $55, $55, $55, $08, $88, $88, $05, $55, $55, $55, $55,
$50, $00, $00, $55, $55, $55, $00, $00);

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  F : TMemoryStream;
  B : TBitmap;
begin
  F := TMemoryStream.Create;
  F.Write(bitData[0], sizeof(bitData));
  F.Seek(0,0);
  try
    B := TBitmap.Create;
    try
      B.LoadFromStream(F);
      Canvas.Draw(0,0,B);
    finally
      B.Free;
    end;
  finally
    F.Free;
  end;
end;

end.

0
 
LVL 20

Author Comment

by:Madshi
ID: 1344294
Hi friend, thanx for your answer. It's exactly what I was looking for...   :-)

Regards, Madshi.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Firemonkey Need Sample for Online Shopping Example. 2 120
Magic Software info 18 125
Delphi: Connect to running MS Outlook 4 48
Delphi and Access based Enumeration 9 47
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now