 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ulla Guest
|
Posted: Wed Oct 08, 2003 5:55 pm Post subject: Is it possible?? Insert Bitmap into the execution file? |
|
|
Hi all, i know this is a strange question... when i compiled my
application first time i used .Res file to insert all my icons
and bitmaps into the execution (EXE) file. Now lets say that i
want to add a new bitmap into the execution file, but i don't
want to do compilation again, is it possible to "plant" the new
bitmap into the execution file somehow? any possible way to do
that?
Thanks!
Ulla
|
|
| Back to top |
|
 |
Ulla Guest
|
Posted: Wed Oct 08, 2003 5:58 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
What i mean is that i want to create an application that get an
execution file (EXE), and a bitmap (BMP), and creates a new EXE
file that include the bitmap inside it.
Thanks!
Ulla
"Ulla" <Ulla456599 (AT) hotmail (DOT) com> wrote:
| Quote: |
Hi all, i know this is a strange question... when i compiled my
application first time i used .Res file to insert all my icons
and bitmaps into the execution (EXE) file. Now lets say that i
want to add a new bitmap into the execution file, but i don't
want to do compilation again, is it possible to "plant" the new
bitmap into the execution file somehow? any possible way to do
that?
Thanks!
Ulla
|
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Oct 08, 2003 6:05 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
Ulla wrote:
| Quote: | Hi all, i know this is a strange question... when i compiled my
application first time i used .Res file to insert all my icons
and bitmaps into the execution (EXE) file. Now lets say that i
want to add a new bitmap into the execution file, but i don't
want to do compilation again, is it possible to "plant" the new
bitmap into the execution file somehow? any possible way to do
that?
|
Well you can place a file containing a picture at designtime
in a TImage. You have to do a make then.
For the rest read the thread "5MB bitmap - Out of Memory"
in this newsgroup;
Hans.
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Oct 08, 2003 6:13 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
Ulla wrote:
| Quote: | What i mean is that i want to create an application that get an
execution file (EXE), and a bitmap (BMP), and creates a new EXE
file that include the bitmap inside it.
|
Think that that is only possible if the exe does already contain a
bmp. Then you can just search the exefile for the occurrence of
the original bmp. If you know the place of the bmp you
can copy the new bmp over the old one. Of course the amount
of bytes of the new bmp should be equal or less than that of
the original bmp.
Hans.
|
|
| Back to top |
|
 |
Ulla Guest
|
Posted: Wed Oct 08, 2003 9:55 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
Hi, first i like to explain why i need it, my application use
a text file in order to create the form and what on it, on this
text file i can write an instructions for creat a TImage on the
form and to display on it the image "MyImage.bmp", this image
is inside the exe file, but what if tomorrow i will want to add
a picture name "NewPic.bmp" and to display it on this TImage
instead of "MyImage.bmp"? i don't want to do another
compilation for that, what i want is that if when i run my
application it detects that the folder contains bmp images it
will run a function (inside the application) that create a new
exe file that will now hold the new bmp inside it also.
What i was thinking of is that if i can detect where in the exe
file end the last bmp, i can copy all the code part (byte by
byte) untill there to another file, then "plant" the code for
the new bmp, and then right after to continue copy the rest of
the original file untill the end, then delete the old exe and
rename the new exe to the name of the exe that was deleted.
But i don't know how to do it... also should i update only one
place in this exe file with the new bmp? or should i split my
updates to deveral places inside the exe?
Thanks!
| Quote: | Think that that is only possible if the exe does already contain a
bmp. Then you can just search the exefile for the occurrence of
the original bmp. If you know the place of the bmp you
can copy the new bmp over the old one. Of course the amount
of bytes of the new bmp should be equal or less than that of
the original bmp.
Hans.
|
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Oct 08, 2003 10:31 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
Ulla wrote:
| Quote: | Hi, first i like to explain why i need it, my application use
a text file in order to create the form and what on it, on this
text file i can write an instructions for creat a TImage on the
form and to display on it the image "MyImage.bmp", this image
is inside the exe file,
|
If you speak about "MyImage.bmp" then that is not an image but a
file. If you say: "this image is inside the exe file" then how
did you get the imagefile in your exe ?
| Quote: | but what if tomorrow i will want to add
a picture name "NewPic.bmp" and to display it on this TImage
instead of "MyImage.bmp"? i don't want to do another
compilation for that,
|
| Quote: | what i want is that if when i run my
application it detects that the folder contains bmp images
|
What folder ? How many images ? What does this have to do with
the other problem ?
| Quote: | it
will run a function (inside the application) that create a new
exe file that will now hold the new bmp inside it also.
|
That I told you in my other post. But then you have to give
the exe a different name.
| Quote: | What i was thinking of is that if i can detect where in the exe
file end the last bmp, i can copy all the code part (byte by
byte) untill there to another file,
|
Do you mean with 'code' all the bytes from the original bitmap ?
Why would you save those to a file ?
| Quote: | then "plant" the code for
the new bmp, and then right after to continue copy the rest of
the original file untill the end,
|
Why ? You can copy only an equal amout or less bytes.
| Quote: | then delete the old exe and
|
The old exe is the exe that is running. This is impossible.
| Quote: | rename the new exe to the name of the exe that was deleted.
|
No, you had to make a copy first, and then change that copy.
| Quote: | But i don't know how to do it...
|
Please be more specific.
| Quote: | also should i update only one
place in this exe file with the new bmp? or should i split my
updates to deveral places inside the exe?
|
???? Where are you talking about ?
This all makes not much sense to me.
Why not load the bmp at runtime? Leave the bmp on the harddisk.
Let your executable open a -text-file which only contains
the path to the bmp file. After haveing read the path, you
load the bitmap. If you want a different bitmap: change the contents
of that -text-file.
Hans.
|
|
| Back to top |
|
 |
Willem Jongman Guest
|
Posted: Sun Oct 12, 2003 4:49 pm Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
Ulla wrote:
| Quote: | this image is inside the exe file, but what if tomorrow i
will want to add a picture name "NewPic.bmp" and to display it
on this TImage instead of "MyImage.bmp"? i don't want to do
another compilation for that
|
I think your best bet is to load your images from file instead
of from resource. In an earlier thread I saw some code you are
using:
Image1->Picture->Bitmap->LoadFromResourceID( (int)HInstance, ID_BITMAP1
);
You could instead say:
Image1->Picture->Bitmap->LoadFromFile("MyImage.bmp");
If "MyImage.bmp" is in the same directory as your exe,
the exe will load the image from file into Image1.
If for some reason you insist in having a stand-alone exe and
want to maintain it without recompiling, the patch solution
described by Hans Galema is your only bet.
Happy coding,
Willem.
|
|
| Back to top |
|
 |
Ron Sawyer Guest
|
Posted: Mon Oct 13, 2003 1:22 am Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
If I understand this request, then yes, this can be done.
Create the program that is using the bitmap. It will need some special
processing that I'll talk about later. Let us call this Graphics.exe.
Create the program that will add the bitmap to Graphics.exe. This
program will:
1. Read in Graphics.exe
2. Write Graphics.exe to a new file
3. Get the current file location (if you used fopen to create the new
exe, use ftell. If you used a files stream, use the equivelent of ftell,
whatever that is.) Store the location in a long.
4. Read in the bitmap
5. Write the bitmap to the end of the new file.
6. Write your long to the end of the file.
Close the exe.
Now in order for Graphics.exe to use the bitmap:
1. Graphics.exe must open itself up - I would use a TStream.
2. Seek to the end of file - 4.
3. Read 4 bytes into a long.
4. Seek from the beginning of the file to the place indicated by the
long you just read.
5. Create a bitmap. I *think* TBitmap has a method to read a bitmap in
from a stream.
6 Close your stream.
I'm pretty sure I remembered every step, but give it a try and play
around.
Ulla wrote:
| Quote: |
What i mean is that i want to create an application that get an
execution file (EXE), and a bitmap (BMP), and creates a new EXE
file that include the bitmap inside it.
Thanks!
Ulla
"Ulla" <Ulla456599 (AT) hotmail (DOT) com> wrote:
Hi all, i know this is a strange question... when i compiled my
application first time i used .Res file to insert all my icons
and bitmaps into the execution (EXE) file. Now lets say that i
want to add a new bitmap into the execution file, but i don't
want to do compilation again, is it possible to "plant" the new
bitmap into the execution file somehow? any possible way to do
that?
Thanks!
Ulla
|
|
|
| Back to top |
|
 |
Dumboo Guest
|
Posted: Tue Oct 21, 2003 11:52 am Post subject: Re: Is it possible?? Insert Bitmap into the execution file? |
|
|
| Quote: | What i mean is that i want to create an application that get an
execution file (EXE), and a bitmap (BMP), and creates a new EXE
file that include the bitmap inside it.
|
from wt i understand from your question
UpdateResource() WIN32 Resource API can be used for the task u need, search
the MSDN it contains a very good example
<snipped from Win32 SDK Help>
The UpdateResource function adds, deletes, or replaces a resource in an
executable file.
Regards
-Dumboo
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|