Solved

Saving pictures outside of the program

Posted on 1998-11-26
22
216 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now