[comp.lang.pascal] putting bitmaps in .exe file

Dan.Bjorklund@samba.acs.unc.edu (Dan Bjorklund) (03/06/91)

 I'm looking for a way to put a series of bitmaps that my Turbo program uses in the .exe file 
so that the program doesn't need to have lots of external files. Is there
an easy way to do this?

Dan.Bjorklund@bbs.acs.unc.edu

ts@uwasa.fi (Timo Salmi) (03/06/91)

In article <2859@beguine.UUCP> Dan.Bjorklund@samba.acs.unc.edu (Dan Bjorklund) writes:
>
> I'm looking for a way to put a series of bitmaps that my Turbo program uses in the .exe file 
>so that the program doesn't need to have lots of external files. Is there
>an easy way to do this?
:

There is some information in /pc/ts/tsfaq17c.arc on how to link .bgi
files, and data files (which is probably what you want) into an
executable.  Available from our site. 

...................................................................
Prof. Timo Salmi        
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

rambaut@castle.ed.ac.uk (A E Rambaut) (03/06/91)

Dan.Bjorklund@samba.acs.unc.edu (Dan Bjorklund) writes:


> I'm looking for a way to put a series of bitmaps that my Turbo program uses in the .exe file 
>so that the program doesn't need to have lots of external files. Is there
>an easy way to do this?

>Dan.Bjorklund@bbs.acs.unc.edu

If you have the bitmaps on disk, you should first go into DOS and use
binobj.exe (included with TP) to create an object file. So if you have a
bitmap called icon1.bit you would type:
	BINOBJ icon1.bit icon1.obj icon1
This would produce a file called icon1.obj with a symbol name of icon1
(this is used to reference it in TP). 
Now back in TP you would add a new procedure to the main body of the
program/unit :

PROCEDURE Icon1; EXTERNAL;
{$L ICON1.OBJ}

This produces a dummy procedure and links your icon1.obj file which has
the same symbol name. Finally in the procedure that you wish to use the bitmap you do
something like the following:

Procedure DrawIcon(x,y:integer);
var
  P:pointer;
begin
  P:=@Icon1;
  putimage(P^,x,y,normalput); {hope this is right - I can't remember the
                               exact format}
end;

The P:=@Icon1 make the pointer point to the procedure icon1 which is not
really a procedure at all but your bitmap masquerading as one. I have a
suspicion that I saw this method used in the Tp manuals but I can't be sure.

Hope this helps.
Andrew.

cd5340@mars.njit.edu (David Charlap) (03/07/91)

In article <2859@beguine.UUCP> Dan.Bjorklund@samba.acs.unc.edu (Dan Bjorklund) writes:
>
> I'm looking for a way to put a series of bitmaps that my Turbo program uses in the .exe file 
>so that the program doesn't need to have lots of external files. Is there
>an easy way to do this?

Well, the BINOBJ utility will make the bitmaps into .OBJ files, which can
be linked, but I'm not sure if you can do anything with them once they're
in that form.  I think Turbo would assume them to be program and not data.

Of course, since you declare a "procedure" name to any object you create
with BINOBJ, you could reference the data through a pointer to it.  For
example, if you named the object "fred", then "@fred" would be a pointer
to the first byte in "fred".
--
David Charlap                   "Invention is the mother of necessity"
cd5340@mars.njit.edu            "Necessity is a mother"
Operators are standing by	"mother!" - Daffy Duck