Solved

Saving pictures outside of the program

Posted on 1998-11-26
22
217 Views
Last Modified: 2010-05-03
Is there a way i can save an array of pictures outside the program?
I have thought about using a resource file or picclip, but i am not sure how to save these files outside of my exe.
Any Ideas how i could?
Digb
0
Comment
Question by:digb
  • 9
  • 7
  • 3
  • +2
22 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1446953
Use the savepicture :)

.

Could you explain more...
0
 

Author Comment

by:digb
ID: 1446954
Ok!
I have a picturebox where a user draws into.
as soon as the user stops (mouse_up), the picture is saved into an array.  There is a command button to add new pictures, but each new picture is saved into an array.
I use the array to create animations by having a different picturebox slowly change pictures by increasing the number value of the array.
But as soon as the user quits the program, the array is resetted and the array is lost.  I want to save the array and all the pictures inside it, into one file (not using save picture since it would create lots of pictures).  I know bitmaps can be accessed from a resource file (.res) but i'm unsure of how to save them to it.  I also know many images can go into a picclip but am unsure how it's possible to save that file, without having it being saved to the form.  (ie instead of saving text to a textbox, i'd rather it became a .txt)
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1446955
You have to create a resource file. In VB5 there is no direct way of doing it. However, you can create a resource file using VC++ version 5 or higher.
A resource file can contain all the pictures and bitmaps needed to your project and it will significantly drop the size of your exe file.
Give me a yell if you need more help.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:digb
ID: 1446956
Oh, really? Hmm, I don't think I can afford to change to VC++ this late in the game, my deadline is quickly approaching...
Is there a way I can use picclip then?
TIA
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1446957
You only use VC++ to create the resource file.
0
 

Author Comment

by:digb
ID: 1446958
I need the user to be able to save the resource file not the programmer.
I want the user to be able to save his work.
0
 
LVL 1

Expert Comment

by:khaledc
ID: 1446959
I am sorry I can not help you but I suggest that you save different bitmaps and save a map file to these bitmaps, map file could be an ascii file that specify where are your bitmaps.
Regards
0
 

Author Comment

by:digb
ID: 1446960
thanks neway!

0
 
LVL 2

Expert Comment

by:trillo
ID: 1446961
I suggeest the following:
First, you have to know how many pictures would you like to save into this single file. Lets say, for example 10.
Let's say your Picture box is 50 x 50 pixels.
Then you could dynamically create PictureBox that is 10 times the width of the original (500 x 50 pixels), then you use the BitBlt API function to paste each one of the bitmaps on the HUGE bitmap, and finally you use the SavePicture method to save the 10 bitmaps on a single file.
0
 
LVL 14

Expert Comment

by:waty
ID: 1446962
The res files are embeded into the exe file at compilation.

You could also save the bitmaps in a Database.
0
 

Accepted Solution

by:
lppjohns earned 100 total points
ID: 1446963
This is fairly unwieldy but it may fit the bill.
You are going to create your own file routine.
Start a binary file and save some framing bytes out to it, these could be any series of four byte values you like Lets say X'FF00AABB
Save your picture byte by byte until completion and then save trailing frame bytes, I use reverse order X'BBAA00FF.
Continue saving all your pictures in the array byte by byte, separated by leading and trailing frame bytes.  This will save an unlimited number of pictures in one file.
When reading back off of the drive, simply search for trailing frame bytes and use them to break the incoming pictures into their respective array slots.  For dynamic sizing you can continually redim preserve the array to allow for a new slot each time a new lead frame
byte is detected.  In this manner you can use any filename you choose and save any size "animation" that you choose.
Let me know what you think.
0
 

Expert Comment

by:lppjohns
ID: 1446964
Glad you liked that solution.

0
 

Author Comment

by:digb
ID: 1446965
i'll like it better if someone tells me how to use a ole
chart to save pics...
:)
0
 

Expert Comment

by:lppjohns
ID: 1446966
If everything were an OLE answer we'd fast run out of a need for the ingenious, original programmer now wouldn't we?
:)
0
 

Author Comment

by:digb
ID: 1446967
well yes...
but that still leaves me with an array of pics i cannot save...
;)
0
 

Expert Comment

by:lppjohns
ID: 1446968
Using that routine, you have saved an array of pictures, if you wanted to make it a dll and instantiate it from within other programs you could do that as well.  It just isn't a nice little pre-packaged routine for you yet, you are going to make it the nice pre-packaged routine for others later.
0
 

Author Comment

by:digb
ID: 1446969
any chance anyone has a sample program illustrating this?
0
 

Expert Comment

by:lppjohns
ID: 1446970
Take that code that I posted here and place it in it's own Activex dll project, name it PicSaver or whatever you like.
Make a public function named SavePic or whatever and allow an array of pictures to
be passed in to it.
Have an inverse Sub named LoadPic and have it's return type be an array of pictures.

Compile this project, this will make it into a dll.

Whenever you want to use it's functionality, add it to a project's project references and then use early binding and set a new object of type PicSaver to instantiate it, you can then use its Savepic or LoadPic methods to do your storage and retrieval.  
0
 

Author Comment

by:digb
ID: 1446971
Sounds Good... cept
for saving it byte by byte,
where does the trail bytes and lead bytes get saved to?

0
 

Expert Comment

by:lppjohns
ID: 1446972
You save the lead and trail bytes out to file as well, you convert their hex values to byte values (x'FF = 255, x'00 = 0, etc) and then convert them to hex for the comparison when you read them back in.
0
 

Author Comment

by:digb
ID: 1446973
That sounds extremely complicated...

0
 

Expert Comment

by:lppjohns
ID: 1446974
It sounds rough, but once you get the concept and you work on it a little bit, it's not a bad deal at all. When you get done with this you will understand the bits and bytes of what you are doing, if you don't want to think about it in hex terms, just save byte values out to disk that you will use later, instead of thinking about it as x'FF00AA55 or whatever, just save out four bytes - 255, 0, 170, 85.  Then when you read in the bytes off of the disk check the value of each byte, (Somewhere between 0 and 255). Write a routine to detect that byte value sequence after each byte is read in.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 70
Need VBS version of Excel date conversion 4 70
VBA/SQL - Connect to SQL server and pull data 4 107
using web browser with BING 40 119
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question