Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Selecting the Image to display in the BinaryFile

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2007, 09:44 AM
Newbie
 
Join Date: Apr 2007
Posts: 5
Default Selecting the Image to display in the BinaryFile

Hi all
I hope this one is not too obvious, but I cannot see how to select the image to retrieve from a BinaryFile. My code just gets each image in sequence but I want to be able to go forwards and backwards and get images based on the position in the file.

My code is

Sub App_Start
'FileOpen(c1,"data.dat",cRandom)
'bin.New1(c1,true)
'bin.EmbedFile (AppPath & "\build.jpg")
'bin.EmbedFile (AppPath & "\wall.jpg")
'bin.EmbedFile (AppPath & "\garden.jpg")
'FileClose(c1)


Form1.Show
FileOpen(c1,"data.dat",cRandom)
bin.New1(c1,true)
'this get the first image in the sequence
Image1.Image = bin.RetrieveImage
End Sub

Sub Num1_ValueChanged
'and then this gets the next but how do I get a specific image
'or get a previous image?

Image1.Image = bin.RetrieveImage
End Sub

Sub Form1_Close
FileClose(c1)
End Sub

Any ideas?
Thanks - Bats
Reply With Quote
  #2 (permalink)  
Old 05-11-2007, 09:59 AM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I'm not all that clued up on this myself but I think you need to add all the images it an imagelist control and then you will be able to select which ever one you want.

Regards,
RandomCoder.
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 05-11-2007, 01:38 PM
Senior Member
 
Join Date: Apr 2007
Location: Arlington, Washington USA
Posts: 180
Default

I've wrestled with this quite a bit. See the Image Explorer post under "Share Your Creations" on this forum. There is a program (with source code) that will scroll back and forth among BMP files stored in a binary file. I have updated this program to handle all supported graphic file types, and will post the final version on the Forum sometime this weekend.

Basically, you have two choices. One, as mentioned by RandomCoder, is to read all the images into an ImageList control. The other is to access an arbitrary image file by specifying its starting location before issuing the RetrieveImage command. The Image Explorer program mentioned above is a tool that can give you that information.

-dlfallen
Reply With Quote
  #4 (permalink)  
Old 05-11-2007, 10:13 PM
Newbie
 
Join Date: Apr 2007
Posts: 5
Default Cool thanks

Hey guys

Thanks for the tips, I'll try check them out.

I did think of another "brute force" method using the RetrieveFile command to export the required image out as say "CurrentImage.jpg" and then reimporting it back into the required location.

Bats
Reply With Quote
  #5 (permalink)  
Old 05-11-2007, 10:27 PM
Newbie
 
Join Date: Apr 2007
Posts: 5
Default The ImageList Control works a treat

Tried out the ImageList control and its great, just need to work out a way of determining how many images are in the file

Sub App_Start
'FileOpen(c1,"data.dat",cRandom)
'bin.New1(c1,true)
'bin.EmbedFile (AppPath & "\build.jpg")
'bin.EmbedFile (AppPath & "\wall.jpg")
'bin.EmbedFile (AppPath & "\garden.jpg")
'FileClose(c1)

Form1.Show
FileOpen(c1,"data.dat",cRandom)
bin.New1(c1,true)
for x = 0 to 2
ImageList1.Add(bin.RetrieveImage)
next x
Image1.Image = imagelist1.Item(0)
End Sub

Sub Num1_ValueChanged
Image1.Image = imagelist1.Item(num1.Value)
End Sub

Sub Form1_Close
FileClose(c1)
End Sub
Reply With Quote
  #6 (permalink)  
Old 05-11-2007, 10:42 PM
RandomCoder's Avatar
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire, UK
Posts: 623
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Instead of the For Next loop you could try a Do Until.
Once again I've not done this myself (I've not had any need yet), but I'd expect you to either receive an EOF or Error which could be used as the signal to drop out of the loop.

Regards,
RandomCoder.
__________________
"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #7 (permalink)  
Old 05-12-2007, 06:27 AM
Senior Member
 
Join Date: Apr 2007
Location: Arlington, Washington USA
Posts: 180
Default

Actually, what usually happens when you try to retrieve a file past the end of the binary file is the program crashes. What I do in my Image Explorer program is check the file positon after each image retrieval. It the image position + 32 is greater than the file size
FileSize(OpenDialog1.File)
then I know I have read the last image in the file.

I have posted the final version of Image Explorer in the Share Your Creations section. The source code there illustrates the method.

-dlfallen
Reply With Quote
  #8 (permalink)  
Old 05-12-2007, 12:18 PM
Newbie
 
Join Date: Apr 2007
Posts: 5
Default

Thanks for the Do While tip works great, note I had to check for the file length less 40

Sub App_Start
'FileOpen(c1,"data.dat",cRandom)
'bin.New1(c1,true)
'bin.EmbedFile (AppPath & "\build.jpg")
'bin.EmbedFile (AppPath & "\wall.jpg")
'bin.EmbedFile (AppPath & "\garden.jpg")
'FileClose(c1)

Form1.Show
FileOpen(c1,"data.dat",cRandom)
bin.New1(c1,true)
Do While bin.Position < bin.Length-40
msgbox("position = " & bin.Position & " length = " & bin.Length)
ImageList1.Add(bin.RetrieveImage)
Loop
Image1.Image = imagelist1.Item(0)
End Sub
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting multiple files using OpenDialog burd27 Questions (Windows Mobile) 2 11-22-2009 10:25 PM
Problem with Binaryfile Pim93 Questions (Windows Mobile) 3 02-20-2008 05:10 PM
selecting multiple lines as remark Stellaferox Basic4ppc Wishlist 3 05-26-2007 10:50 AM
Move an image inside an image control Cableguy Questions (Windows Mobile) 5 05-14-2007 07:40 PM
BinaryFile Error dlfallen Bug Reports 2 05-01-2007 08:34 PM


All times are GMT. The time now is 06:10 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0