Solved

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

Posted on 1998-10-25
2
286 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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