Board index » delphi » Compiling Bitmaps into Executable - TImageList with Jpegs? (D5)

Compiling Bitmaps into Executable - TImageList with Jpegs? (D5)

Admittedly I'm probably missing the obvious here, but it's been a
long, cold Ohio winter and the brain may still be hibernating.

I'm looking for a relatively simple way to include a number of jpeg
images (all the same dimensions) within the compiled executable.
tImageList would be one way, but I'd hate the extra payload incurred
by using bmps. If that can't be accomplished, a possibly acceptable
alternative would be a single external file from where the graphic
could be called (DLL?).

Sorry if that sounds simplistic, but I'm really a better designer than
coder. So come on now, Delphi gurus . . . any thoughts? Thanks in
advance!

Ken

E-Mail: You know the drill below.
kpenn...@nomorespam.pan-arts.com

 

Re:Compiling Bitmaps into Executable - TImageList with Jpegs? (D5)


You can include the Jpeg images in a resource.

1. Create a file called images.rc with the following contents:

IMAGE1 RCDATA "C:\Images\Image1.jpg"
IMAGE2 RCDATA "C:\Images\Image2.jpg"
IMAGE3 RCDATA "C:\Images\Image3.jpg"
etc.

2. Use the Borland Resource Compiler brcc32.exe to create images.res:

brcc32 images.rc

3. Include the images.res file in your project:

{$R images.res}

4. Load an image from the resource:

var
  S: TStream;
begin
  S := TResourceStream.Create(hInstance, 'IMAGE1', RT_RCDATA);
  try
    Image1.Graphic := TJpegImage.Create;
    Image1.Graphic.LoadFromStream(S);
  finally
    S.Free;
  end;
end;

"Ken & Kerry Pennink" <e-m...@address.below> schreef in bericht
news:3aaf603a.3298916@news.tryi.com...

Quote
> Admittedly I'm probably missing the obvious here, but it's been a
> long, cold Ohio winter and the brain may still be hibernating.

> I'm looking for a relatively simple way to include a number of jpeg
> images (all the same dimensions) within the compiled executable.
> tImageList would be one way, but I'd hate the extra payload incurred
> by using bmps. If that can't be accomplished, a possibly acceptable
> alternative would be a single external file from where the graphic
> could be called (DLL?).

> Sorry if that sounds simplistic, but I'm really a better designer than
> coder. So come on now, Delphi gurus . . . any thoughts? Thanks in
> advance!

> Ken

> E-Mail: You know the drill below.
> kpenn...@nomorespam.pan-arts.com

Re:Compiling Bitmaps into Executable - TImageList with Jpegs? (D5)


Quote
"M.H. Avegaart" <avegaartNOS...@mccomm.nl> wrote:

M.H.:

Thanks for your clear and concise response. I'll try it out this
evening. I'd also like to experiment with including the .rc file in
the Delphi project, and compiling it from there rather than the
command line.

Ken

Quote
>You can include the Jpeg images in a resource.

>1. Create a file called images.rc with the following contents:

>IMAGE1 RCDATA "C:\Images\Image1.jpg"
>IMAGE2 RCDATA "C:\Images\Image2.jpg"
>IMAGE3 RCDATA "C:\Images\Image3.jpg"
>etc.

>2. Use the Borland Resource Compiler brcc32.exe to create images.res:

>brcc32 images.rc

>3. Include the images.res file in your project:

>{$R images.res}

>4. Load an image from the resource:

>var
>  S: TStream;
>begin
>  S := TResourceStream.Create(hInstance, 'IMAGE1', RT_RCDATA);
>  try
>    Image1.Graphic := TJpegImage.Create;
>    Image1.Graphic.LoadFromStream(S);
>  finally
>    S.Free;
>  end;
>end;

Other Threads