?
Solved

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

Posted on 1998-10-25
2
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
inter earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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