Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Share Your Creations
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Share Your Creations Show your developed application to Basic4ppc community. Please include source code if possible.


Embed your images into a .DAT file with this builder


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-08-2008, 12:00 PM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default 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

That's it....

Happy Programming!
Attached Files
File Type: sbp ImageEmbedBuilder.sbp (3.7 KB, 81 views)

Last edited by Oran : 02-08-2008 at 12:04 PM.
Reply With Quote
  #2 (permalink)  
Old 02-08-2008, 12:06 PM
Newbie
 
Join Date: Jan 2008
Posts: 5
Default

Very Nice,

THANK YOU

Smurfy
Reply With Quote
  #3 (permalink)  
Old 02-10-2008, 08:04 PM
klaus's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 433
Awards Showcase
Competition Winner 
Total Awards: 1
Default

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
Attached Images
File Type: jpg ImEmB1.jpg (20.7 KB, 31 views)
File Type: jpg ImEmB2.jpg (15.1 KB, 27 views)
File Type: jpg ImEmB3.jpg (12.3 KB, 17 views)
File Type: jpg ImEmB4.jpg (22.1 KB, 25 views)
Attached Files
File Type: zip ImEmBV1_8.zip (115.8 KB, 54 views)

Last edited by klaus : 04-11-2008 at 05:32 PM.
Reply With Quote
  #4 (permalink)  
Old 02-10-2008, 10:57 PM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default

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 ///
Reply With Quote
  #5 (permalink)  
Old 02-11-2008, 05:01 AM
klaus's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 433
Awards Showcase
Competition Winner 
Total Awards: 1
Default

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
Reply With Quote
  #6 (permalink)  
Old 02-11-2008, 06:55 AM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,024
Default

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

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD
Reply With Quote
  #7 (permalink)  
Old 02-11-2008, 09:40 PM
klaus's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 433
Awards Showcase
Competition Winner 
Total Awards: 1
Default

Hello
I added a configuration for the file extension, so the user can choose what he wants.
The program is updated in my previous post.

Klaus
Switzerland
Reply With Quote
  #8 (permalink)  
Old 02-12-2008, 08:57 PM
Junior Member
 
Join Date: Jan 2008
Posts: 12
Default

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.
Reply With Quote
  #9 (permalink)  
Old 02-12-2008, 09:16 PM
klaus's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 433
Awards Showcase
Competition Winner 
Total Awards: 1
Default

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 by klaus : 02-19-2008 at 09:22 PM.
Reply With Quote
  #10 (permalink)  
Old 02-13-2008, 09:15 AM
klaus's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: Switzerland
Posts: 433
Awards Showcase
Competition Winner 
Total Awards: 1
Default

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 by klaus : 04-08-2008 at 07:15 AM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
setup builder question jerryjukem Questions & Help Needed 1 05-05-2008 05:15 AM
Embed images in the exe alfcen Basic4ppc Wishlist 2 03-22-2008 11:46 AM
Embed and retrieve images in a data file Erel Code Samples & Tips 10 02-18-2008 07:23 AM
Different Target for Setup Builder Woinowski Additional Libraries 0 01-07-2008 11:37 AM
Setup Builder Modification Sven Kommers Additional Libraries 4 05-20-2007 04:59 AM


All times are GMT. The time now is 01:15 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0