Embed your images into a .DAT file with this builder

Oran

Member
Licensed User
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

That's it....

Happy Programming!
 

Attachments

  • ImageEmbedBuilder.sbp
    3.7 KB · Views: 558
Last edited:

klaus

Expert
Licensed User
Longtime User
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
 

Attachments

  • ImEmBV1_8.zip
    115.8 KB · Views: 478
  • ImEmB1.jpg
    ImEmB1.jpg
    20.7 KB · Views: 395
  • ImEmB2.jpg
    ImEmB2.jpg
    15.1 KB · Views: 353
  • ImEmB3.jpg
    ImEmB3.jpg
    12.3 KB · Views: 343
  • ImEmB4.jpg
    ImEmB4.jpg
    22.1 KB · Views: 343
Last edited:

Oran

Member
Licensed User
Klaus,

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....

Oran ///
 

klaus

Expert
Licensed User
Longtime User
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.

Klaus
Switzerland
 

Cableguy

Expert
Licensed User
Longtime User
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...
 

Oran

Member
Licensed User
Klaus,

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.
 

klaus

Expert
Licensed User
Longtime User
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.

Klaus
Switzerland
 
Last edited:

klaus

Expert
Licensed User
Longtime User
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.

Update in my first post or this thread

Best regards
Klaus
Switzerland
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
The evolution is awsome...
btw when will we have the new version of iconedit with the image.dat files?

Can you please add an optimized compiled exe for the device, I'm having troubles compiling it...
 

klaus

Expert
Licensed User
Longtime User
Hello cablaguy
The compiled version for the device is now included in the last update.

I have created in EmbeddedImagefile with all the images of the IconEditor, but for the moment I have a problem when I assign images to ImageButtons in the IconEditor, I get an out of memory message. I have not yet found what happens.

Will keep you informed.

Best regards
Klaus
Switzerland
 

Cableguy

Expert
Licensed User
Longtime User
Hi Klaus...Glad to ear from you...I didnt expect the image embeding would be such a pain...:sign0161::sign0013:
If you'd like, I can also have a Go at it....and see what cames up of it....
Here in Portugal we have a saying that reads "Two heads think better than One"....:sign0188:
 

klaus

Expert
Licensed User
Longtime User
Hi Paulo,
The problem of the ImageButtons is solved, yesterday I was looking closer to what happens, before sending you the code, and found a problem with ImageButtons. You will find the details in:
http://www.b4x.com/forum/showthread.php?t=1766

I did it late in the evening, during the day I was hiking in the mountains. I have joinded a picture from yesterday, just to allow some dreaming.

Best regards
Klaus
Switzerland
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
DayDreaming........
Were do i sign in for a job there?!?!?!?:sign0188::sign0188:
 

dzt

Active Member
Licensed User
Hi Klaus,

Seeing this makes it more difficult for me to concentrate on my work. I can't wait for tomorrow to go for skiing.
Of course nothing like the Alps:)
 

Oran

Member
Licensed User
Klaus,

I like it! Keep it coming!!! :) I like spreading an "Idea Virus"...

For those that are not aware of this book... I HIGHLY recommend it, it's a good read..

By Seth Gordon... "Unleashing the Idea Virus" http://www.sethgodin.com/ideavirus/ this book shows you how to think "outside" of the box...

Anyways... just my .02 worth.. :)

Dave ///
 

alfcen

Well-Known Member
Licensed User
Longtime User
I did it late in the evening, during the day I was hiking in the mountains. I have joinded a picture from yesterday, just to allow some dreaming.
Best regards
Klaus
Switzerland

Hi Folks
Here is another splash screen image to 'embed' in your dreams :)
Haisai from the Ryukyus where snow is being imported for the kids.
 

Attachments

  • iriomote.jpg
    iriomote.jpg
    67.5 KB · Views: 300
Top