Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed 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, 10: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, 10:59 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
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.
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 05-11-2007, 02:38 PM
Junior Member
 
Join Date: Apr 2007
Location: Olympia, Washington USA
Posts: 24
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, 11: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, 11: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, 11:42 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
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.
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #7 (permalink)  
Old 05-12-2007, 07:27 AM
Junior Member
 
Join Date: Apr 2007
Location: Olympia, Washington USA
Posts: 24
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, 01: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 On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 10:05 PM.


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