Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 storing bitmaps in memory
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

Vankwysha
Squire

Australia
43 Posts

Posted - May 07 2005 :  04:13:53 AM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
Hmmm, I spose that is a good point. Maybe I'll worry about this stuff once I'm done.

Go to Top of Page

Crysstaafur
Squire

USA
37 Posts

Posted - May 07 2005 :  06:54:34 AM  Show Profile  Visit Crysstaafur's Homepage  Send Crysstaafur an AOL message  Reply with Quote
One quick question Van, the 'variable' that you are trying to stash your image into, is it
an actual variable, a label for an object, an indexed array, or a pointer address?

Also if the function you are trying to call is asking for a filename, the only two ways I know of
feeding it info break down to simple and hard as hell...

if you've settled the file issue then ignore the rest of this post... :)

simple:feed a file into the function.(the state of the file doesn't matter as long as it matches what it expected when said function is called...)

complex:(sighs) try finding out what memory address or object the function is attempting to load the image into, then simply pop the information into that. This undoubtedly would require some skill with win32 asm or an uncanny grasp of memory manipulation.. either way.. the issue of learning the internals of the functions binary is an issue.. I am still not 100% on whether that would even work...

2dCoder: 'So long and thanks for all the fish...' lol
Go to Top of Page

Vankwysha
Squire

Australia
43 Posts

Posted - May 07 2005 :  7:36:31 PM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
The function can take a FileStream or a System.Drawing.Bitmap object, so eventually I will load my bitmap into one of those, but for now I'll just concentrate on converting the rest of my game from VB6 to VB.NET.
Go to Top of Page

2dcoder
Knave

83 Posts

Posted - May 08 2005 :  04:12:23 AM  Show Profile  Reply with Quote
hmm, curious... since it sounds like you already have it working in vb6, what benefits do you see going to VB.Net? Better performance, better compatbility for end users ? ?
Go to Top of Page

Vankwysha
Squire

Australia
43 Posts

Posted - May 08 2005 :  3:55:26 PM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
Well, I didn't have it working in VB6 to start with, since then I've made some major revisions to the design of the game that just wouldn't work with VB6, and also because I no longer own VB6.
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 09 2005 :  10:51:06 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
The fact that you can load data from a "stream" or "bitmap" ojbect seems to have been ignored in this thread. The "stream" object allows you to load graphical data from memory, which is what you're asking about. The trick is to make sure that the data in your stream is uncompressed, which is what you have to do regardless of how you store or use the data.

Are you having trouble reading data from a file or are you having trouble uncompressing the data or what? The concept of what you need to do is simple, Disk -> Uncompress -> Memory -> CreateSurfaceFromMemory. Lachlan already told you how to do that last part, use system.IO.Stream.

Go to Top of Page

Vankwysha
Squire

Australia
43 Posts

Posted - May 10 2005 :  04:24:52 AM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
So far, I've been able to compress and decompress my images, and I know how to load a bitmap or stream object into the draw sub, however, I haven't worked out how to make the link between. Once I decompress the data, it just sits in a binary variable. How do I then load that variable into a stream (or bitmap)?
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 10 2005 :  12:25:16 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Well, I don't know anything about your image format, but you need to convert it to a byte array. Then simply use this code to create your stream.
  
Dim Data() As Byte
ReDim Data(10)  
Dim S As System.IO.MemoryStream  
S = New System.IO.MemoryStream(Data)  
  

Go to Top of Page

Vankwysha
Squire

Australia
43 Posts

Posted - May 11 2005 :  04:40:52 AM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
Well, I've finally figured it out. It's taken a while, but I've now got my bitmaps decrypted successfully and loaded as sprites. I'd just like to thank all of you for your time and help.
Go to Top of Page

Eric Coleman
Gladiator

USA
811 Posts

Posted - May 11 2005 :  10:15:34 AM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Any tips or suggestions for the rest of us on how you did it?
Go to Top of Page

Vankwysha
Squire

Australia
43 Posts

Posted - May 14 2005 :  07:45:22 AM  Show Profile  Click to see Vankwysha's MSN Messenger address  Reply with Quote
I haven't had time over the last few days to fully implement my solution, but I have got the basics working.

Basically, I've simply removed the compression from the file format (as it overly complicates things) and simply have each of the bitmaps one after the other in a single file. One of my friend designed a DLL which contains the necessary classes and functions for packing and unpacking bitmaps into a single file, and once I fully understand this I'll be happy to share the full solution.

However, once the images have been unpacked, I simply store them in byte arrays and then load them into memory stream objects.

Again, thanks all round.
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.16 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.