Solved

Saving pictures outside of the program

Posted on 1998-11-26
22
218 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 59
Macro: print each sheet to pdf using ExportAsFixedFormat 11 52
How to compare ms sql hashbytes results within vb6 5 84
RUNRMTCMD from AS/400 12 68
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

840 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