|
-
Nov 21st, 2002, 02:53 AM
#1
Thread Starter
New Member
Loading from memory
hey all, Working with a graphics app in VB for the frist time (usually dont use VB).
Basically, I want to open a file (that contains seperate forms of data, sounds, images etc.) Then, *without* dumping into a temporary file or anything, i want to load an image from it. I know the format very well, so i know where all images and such are. This should be possable right? If not I'm kinda screwed, the other language i develop in can do this, but doesnt off win32 interface.
-
Nov 21st, 2002, 06:30 AM
#2
Fanatic Member
Code:
Dim iFileNum as integer
Dim sMemBuf as string
Dim lMemSize as long, lStartPos as long
iFileNum = freefile
open "myfile.ext" for binary as #ifilenum
lmemsize = <whatever you set it>
smembuf = space$(lmemsize)
lstartpos = <something>
get #ifilenum, lstartpos, smembuf
close #ifilenum
Note, in VB file positions are one-based! Not zero-based in languages such as C/C++.
In this example I'm using a string as a buffer to store data into. It can even hold non-ascii characters and doesn't convert returns to Windows-format.
Since you know the used file format well, you should be able to determine what the memsize and startpos will be.
-
Nov 21st, 2002, 06:53 AM
#3
Thread Starter
New Member
w00t. Ok, hehe, ill humor you some more with my lack of VB experience. How could i get this into a picturebox, without saving it..or hell, with saving it if i have too
-
Nov 21st, 2002, 07:28 AM
#4
Frenzied Member
Read until you are the offset into the file where the graphic starts.
Then write the graphic to a file.
Assuming the graphic is of a type Windows COM controls can use then do
Code:
' with a picture box on the form
Picture1.LoadPicture "filename"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|