Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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