Embed your images into a .DAT file with this builder
This application allows you to build a simple .DAT file to contain your embedded images. It will allow you to distribute only one .DAT file instead of all your .BMP images. Makes it nice to keep your distribution with as little files as possible.
Basic knowledge information -- Images added to the .DAT file are indexed starting with zero up to the amount of images that you have. For example if your application uses 10 images (example below) then your .DAT index will be 0-9
INSTRUCTIONS (FOR THIS EMBED BUILDER)
1.] Count how many images you will want to have in your application and the order you want to add them (not that that matters)
2.] Decide on a file name, this example uses Images.Dat
3.] Use the syntax: alFiles.Add("imagename.jpg") <--- this can be .JPG or .BMP -- does not matter
4.] Either add more alFiles lines or delete depending on the count of images you came up with in step 1.
5.] From your desktop, simply just --> RUN <-- the application, DO NOT COMPILE IT..
6.] The ImageBuilder will then search for and delete any prior versions of your Image.dat and then rebuild it for you.
7.] TIP! All the image files you are adding should be in the same folder as this .SBP folder
8.] When done, you will have a single .DAT file to put in your application folder
INSTRUCTIONS TO CALL AN IMAGE FROM YOUR .DAT FILE FROM YOUR APPLICATION
1.] From your main form, add an ArrayList component and name it IL1 (for Image List 1) and position it out of the way of any of your other controls.
2.] Create the following SUB anywheres in your applications .SBP code:
Sub RetrieveImages (file)
FileOpen(c,file,cRandom)
bin.New1(c,false)
num = bin.ReadInt32 'read the number of images.
For i = 1 To num
IL1.Add(bin.RetrieveImage)
Next
FileClose(c)
End Sub
3.] Next, on the App_Start event, add the following line: RetrieveImages("Images.Dat")
4.] On each form where you wish to display an Image control, use the following code: ImageControlName.Image = IL1.Item(5)
5.] Example: imgAbout.Image = IL1.Item(5)
Where in the above example, I have an image control called imgAbout and the photo for that is in the .DAT file in Index position 5
Hello Oran
I intend to use your idea for the images of the IconEditor.
But I have more than 50 images, and found it boring to enter all the names into the code.
So I took the liberty to add some functionalities to your code:
- load the filenames from a directory
- handle the files in a listbox remove, up, down
- make the DAT file
- read a DAT file and view the different images
I have added the new version with
- source code
- desktop exe file
Hope this complement will also help others.
Klaus
Switzerland
Update 2008. 02. 11 V1.2
Added a configuration for the file extension.
Update 2008. 02. 13 V1.3
Added Save list function, saves the last used list and loads it at the next start of the program.
Added insert (<) function, inserts a single file before the selected item in the list.
Update 2008 02. 13 V1.4
Added Add (+) function
Added compiled version for device
Update 2008 02 18 V1.5
Added a save function allowing to save images back into files
Update 2008 03 04 V1.6
Corrected an error in the Insert function
Update 2008 03 05 V1.7
Changed program name to 'ImEmB' , name too long on the device.
Added *.gif and *.png file types for embedding
Replaced some Buttons by ImageButtons with the images embedded in a file.
The look has changed a bit.
Update 2008 04 11 V1.8
In the Viewer the proram allows now to display 1, 4 or 9 images
That's awesome! Good work. That's what this community is all about.... Actually I can't really take all the credit. I found some scraps of code around the forum and put that little tutorial together but you took it to the next level. Awesome! I will use this to make the files for my apps....
Hello Oran
I am glad that you agree with the evolution of the ImageEmbedBuilder.
Have you made some tests about the program loading speed on the device when you have a certain number of images.
What do you think about changing the file extension from DAT to IMG decause the SetupBuilder generates also DAT files and this could be confusing.
the File extension will be of no importance as long as t is known by the program...
I have a trend to create my own extension for some of my programs, so that I know wich files to look for..
you could take the multi thread Path and load the images, in whatever file extension you wish, along side with a small splash screen...
__________________
Paulo Gomes - Porto, Portugal - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate) B4PPC DLL Version Listing - B4Android DLL Version Listing
I find the speed to be good. The addition of extension ability is good and I agree with Cableguy that it does not matter so long as your program knows it. I also use an extension that will save me lots of time in updating or the such.
Hello both,
I agree with you that the extension doesn't matter, but in the first version the extension was DAT and if you read a wrong DAT file which was not an ImegeEmbedBitmap file there was an error. But anyway with the extension configuration it is more flexible.
I have not yet tested the speed.
There is a new update to version V1.3
After using the program I found that the following functions were missing.
- Added a Save list function, saves the last used list and loads it at the next start of the program.
- Added an Insert function, inserts a single image before the selected item in the list.