Solved

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

Posted on 1998-10-25
2
280 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
Comment Utility
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
Comment Utility
Hi friend, thanx for your answer. It's exactly what I was looking for...   :-)

Regards, Madshi.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

6 Experts available now in Live!

Get 1:1 Help Now