-
Sorry for the Subject, but I really didn't know how to describe my problem real short.
I am searching an easy method to Load/save a bitmap, from or in a file with more infos. I want to store a whole Level for a game into one File. So Is there a way that isn't totally slow, to save some types, and than a bitmap to one file?
-
Of course there is. I just want to know why you want to have a bitmap in a level before you do something stupid.
-
Hehehe before I do something stupid?
I need a background bitmap in my level. This time the game isn't tilebased. No fear I don't try to move a 30000*1024 bitmap over the screen. All I need is a backround Bitmap, that is only used in one Level. The bitmap will be 800*600. Actually it is more than a background, it is the whole level. But I need to store some other information, like some collision infos, and some cordinates for animations.
I hope this was confusing enough :) to give me the answer. I think I found a way to do it, but I don't like it to much.
-
You want it all in one file? Welli was working on something similar to .PAK files in quake a while ago so if you want you could as well continue on my work if you want, (it's not totally complete and there might be some bugs)
-
Sure there is a way!
Just attach the info you need at the end of the map. If I'm right, the BMP will not be corrupted and you can load it perfectly. Use a keyword like <-- MAP FILE INFO START HERE --> to know where the info begins.
Try it and reply back. If it doesn't work, I know of another way.
-
Hm I am pretty sure it works, but if I want to save more than one bitmap, it wont work
-
Yep, there are dib's but i've never used them, they are like bitmap stacked on each other i think..
-
Hm I am thinking about creating DCs in the Memory, and loading arrays for the bitmap data. Than I use copymemory to copy the Array Data to the Bitmap DC. Will this work?
-
well if i'm correct what you're trying to do is loading a bitmap with the array and attach it to a DC, that would work if you had a 24 bit image otherways you would have to use a palette, and stuff...
-
Now, wouldn't it be simplier to have one program (the map editor) that converts the image to yor own format and adds all the stuff you want?
I have a module with functions to read and write to an INI file. It couldn't get any simplier:
Code:
'This module has 2 functions to read and write to INI files.
'APIs:
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpINIPath As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpString As Any, ByVal lpINIPath As String) As Long
'Vars:
Dim INIfPath As String
Public Function ReadINI(ByVal Section As String, ByVal Key As String, ByVal INIPath As String) As String
Dim RetStr As String
If Dir(INIPath) = "" Then Exit Function
RetStr = String(255, Chr(0))
ReadINI = Left(RetStr, GetPrivateProfileString(Section, ByVal Key, "", RetStr, Len(RetStr), INIPath))
End Function
Public Function WriteINI(ByVal Section As String, ByVal Key As String, ByVal KeyValue As String, ByVal INIPath As String) As Integer
'Function returns 1 if successful and 0 if unsuccessful
If Dir(INIPath) = "" Then Exit Function
WritePrivateProfileString Section, Key, KeyValue, INIPath
WriteINI = 1
End Function
Try pasting it into a module! Then it would be simple, just write INI keys to a bmp and voila, there you have! If you want different bitmaps, if they have a fixed size, make different sections of the bitmap, like the first half is the map and the second half is a mask for testing collisions (you surely have seen this before). Otherwise, you can simply have some INI keys give you the coordinates/sizes of each section!
-
Forgot to say, don't confuse INI sections with BMP sections. This is how an INI file looks like:
[section1]
key1=This is key 1's value
key2=...
[section2]
key1=section 2's key 1
key2=...
key3=...
You can name keys and sections as you like, but try using only numbers and letters. The keys' values can be anything that doesn't have a line break.
The BMP sections are different, what I meant is that an area is the map, another area is the player's sprite, another one is the first enemy's sprite...