Board index » delphi » Saving bitmaps into an exe

Saving bitmaps into an exe

Hi,

I want to save bitmaps in my exe file (at design time). I can't use the
timagelist because the images are too big for it. And I don't want to use
the delphix components. Does somebody know a solution?
Maybe saving it into a res file or something else? (Please give an example
for the resource solution)

Thanks,

Kevin.

 

Re:Saving bitmaps into an exe


This is a resource compiler script I use to save paradox tables as a
resource.

LEAVEDB TABLEFILE d:\study\clean\Leave.DB
LEAVEMB TABLEFILE d:\study\clean\Leave.MB
LEAVEPX TABLEFILE d:\study\clean\Leave.PX

The last column is the file path, the first two are arbitrary names and
types used to extract them.

This code extract them to file

(I was sent this, I didn't write it)

procedure ExtractRes(ResType, ResName, ResNewName: string);
var
  Res: TResourceStream;
begin
  Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
  Res.SavetoFile(ResNewName);
  Res.Free;
end;

you can also extract them to memory as a stream I think , but I don't
have any code to hand.

Andrew
Andrew

Re:Saving bitmaps into an exe


"TP" <kevi...@pi.be> a crit dans le message news:
9rsm4g$kn...@news.planetinternet.be...

Quote
> Hi,

> I want to save bitmaps in my exe file (at design time). I can't use the
> timagelist because the images are too big for it. And I don't want to use
> the delphix components. Does somebody know a solution?
> Maybe saving it into a res file or something else? (Please give an example
> for the resource solution)

> Thanks,

> Kevin.

Here's the resource solution:

First, create a .RC file using notepad. Ex: MyBitmaps.RC
In this file, you add a line for each bitmap you need to include.
Ex: LOGO1 BITMAP LOADONCALL MOVEABLE DISCARDABLE "logo1.bmp"
Ex: LOGO2 BITMAP LOADONCALL MOVEABLE DISCARDABLE "logo2.bmp"

Where "logo1.bmp" is the path and filename for each bitmap (my files are all
in the same directory).
Then you invoke, in a DOS box, BRCC32, the Borland Resource Compiler, to
create the resource file.
Ex: BRCC32 -v MyBitmaps.RC
MyBitmaps.RES is created.

In a form of your Delphi project, you add {$R MyBitmap.RES} under the line
{$R *.DFM}

In your code, you load the bitmap like this:
Image1.Picture.Bitmap.LoadFromResourceName(HInstance,'LOGO1');
where Image1 is your TImage and LOGO1 is the bitmap you want to load.

Hope that helps...

Re:Saving bitmaps into an exe


Christian:

What is the differnce between you rc script and mine (apart from the
fact that mine is simpler and trial and error and I don't really
understand it <G>)?

What do the LOADONCALL MOVEABLE DISCARDABLE do?

Do I have RC documentation somewhere in my Delphi installation?  If not
do you know where?

Just curious, my setup works for me.

Cheers

Andrew

Re:Saving bitmaps into an exe


Hi Andrew,
the reason I posted my solution is because Kevin wanted to use bitmaps, and
your example used paradox tables. Since I don't know if Kevin is comfortable
with resource files, I wrote a quick tutorial to make sure he can test this
solution and determine if it's the best for his need.

My RC files comes from the old days, back when I was using Visual C++ 1.0
(that was the 16 bits version). The files were generated by a wizard, so I
always assumed it had the right syntax. I think the "LOADONCALL MOVEABLE
DISCARDABLE" section is for memory optimization, if I remember right:   the
bitmap is loaded into memory only when needed and the memory segment can be
manipulated by the virtual memory manager (you know, that kind of stuff).
This was for 16 bits though, and I don't know if it still makes sense to use
it in a 32 environment. BRCC32 didn't gave me any warnings, so I assume I'm
OK.

I don't have any documentation on resource files, I am just relying on old
stuff I wrote. I you find any documentation, let me know, I too would
interested.

Bye
Christian

"Andrew Skinner" <skin...@summerfld.demon.co.uk> a crit dans le message
news: 3BE3B2BC.91B82__BEGIN_MASK_n#9g02mG7!__...__END_MASK_i?a63jfAD$z__@summerfld.demon.co.uk...

Quote
> Christian:

> What is the differnce between you rc script and mine (apart from the
> fact that mine is simpler and trial and error and I don't really
> understand it <G>)?

> What do the LOADONCALL MOVEABLE DISCARDABLE do?

> Do I have RC documentation somewhere in my Delphi installation?  If not
> do you know where?

> Just curious, my setup works for me.

> Cheers

> Andrew

Re:Saving bitmaps into an exe


In article <p22F7.38253$Cu4.44...@news.tor.primus.ca>, "Christian Boivin"

Quote
<boivin_christ...@hotmail.com> writes:
>I think the "LOADONCALL MOVEABLE
>DISCARDABLE" section is for memory optimization, if I remember right:   the
>bitmap is loaded into memory only when needed and the memory segment can be
>manipulated by the virtual memory manager (you know, that kind of stuff).
>This was for 16 bits though, and I don't know if it still makes sense to use
>it in a 32 environment.

These words are for a 16-bit environment and are ignored in a 32-bit
environment (source MSDN).

Alan Lloyd
alangll...@aol.com

Re:Saving bitmaps into an exe


Thanks.

AS

Other Threads