 |
 |

06-15-2004, 12:22 PM
|
|
Regular
|
|
Join Date: Mar 2003
Posts: 89
|
|
Pictures in a .dll or something like that?
|
Right now in my project, which is a simple Monopoly game with only 2-d graphics and no music or video, I am up to a 10 MB .exe file, simply because of all the picture files it needs for the Deeds, player tokens, chance cards, etc. Right now all the pictures are in ImageLists so that the user can't just go into the program folder and change the pictures. What I'm wondering is if there is a way to put all the picture files into a .dll or some type of file like that (I'm a complete noob when it comes to anything but .exe programming) so that when I wanna release a new version of my exe (for instance in beta testing) I dont have to send my testers a 10 MB file, I can just send them a small exe file and let them use the .dll file they already have. I hope this makes sense. Please advise, thanks.
|
|

06-15-2004, 01:34 PM
|
 |
Still asleep...
Retired Leader * Expert *
|
|
Join Date: Nov 2003
Location: IronForge
Posts: 2,694
|
|
Perhaps a rescource file?
Edit: err.. nevermind, those apparently are wirtten to the exe
Are you farmiliar with File I/O? You may be able to read/write the files from a seperate folder in your program and not use the Imagelist.
Are you concerned that the user will change the images, delete the files by accident or just plain steal the artwork?
|
__________________
~ Jason
Use [vb][/vb] tags when posting code :) || Search the forum and MSDN|| Check out the Posting Guidelines
Last edited by noi_max; 06-15-2004 at 01:50 PM.
|

06-15-2004, 02:02 PM
|
|
Centurion
|
|
Join Date: Feb 2003
Posts: 150
|
|
You could write your own resource file. You put whatever extension you want on it, and nobody would be able to simply open it up in paint and edit images (or steal them). It's fairly simple ...
You'd have a type (I like to call this type HEADERINFO) that describes whatever's in your resource file. You'd have another type DATA (or you could simply make a string array called data) where you'd put data for the files. You use the header type to tell how many files there are, redimension the string array to that many entries, and use Get filenum, , Data() to retrieve the information. You could then save the information to whatever filename you need. Here are some basic routines that may get you started:
Code:
'Data format:
' VERSIONTYPE
' -GUID
' -Major
' -Minor
' -Revision
' HEADER
' -Filecount
' -FilenameLens(*Filecount)
' -Filenames(*Filecount)
' -DataLen(*Filecount)
' DATA
' -Data(*Filecount)
'==================================='
' Constants
'==================================='
Private Const DEFAULT_EXTENSION As String = ".g3p" '\\ Default extension of files created by this class.
Private Const WATERMARK_GUID As String = "SomeString01" '\\ Unique code so different
'\\ versions of this class don't
'\\ run into compatibility
'\\ problems.
'==================================='
' Types
'==================================='
Type WATERMARK_VERSION
GUID As String '\\ Identifier code
MajorDLL As Long '\\ Major version
MinorDLL As Long '\\ Minor version
RevisionDLL As Long '\\ Revision number
End Type
Type WATERMARK_HEADER
lngFileCount As Long '\\ number of files contained within the resource file.
FilenameLens() As Long '\\ The length of each filename (bytes)
Filenames() As String '\\ The filenames of the files
DataLen() As Double '\\ The FileSize of each of the files
End Type
Type WATERMARK_DATA
Data() As String '\\ Data for each of the files in this resource file.
End Type
'============================================================================================='
' Public Sub: SaveFile
' Purpose: Saves a watermarked file of the specified name.
'============================================================================================='
Public Sub SaveFile(ByVal strFilename As String, FilenameList() As String, Optional blnEncrypt As Boolean = False, Optional bytEncryptShift As Byte = 128)
Dim VersionInfo As WATERMARK_VERSION
Dim HeaderInfo As WATERMARK_HEADER
Dim Data As WATERMARK_DATA
Dim lngCounter As Long '\\ A temporary counting variable
Dim lngCounter2 As Long '\\ Another temporary counting variable
Dim dblCounter As Long '\\ A large counting variable
Dim strTemp As String '\\ A temporary string variable
Dim strEncrypt As String '\\ A temporary string that holds whatever's been encrypted so far
Dim hFile As Long
With VersionInfo
.GUID = WATERMARK_GUID
.MajorDLL = App.Major
.MinorDLL = App.Minor
.RevisionDLL = App.Revision
End With
With HeaderInfo
.lngFileCount = 0
ReDim .FilenameLens(0)
ReDim .Filenames(0)
ReDim .DataLen(0)
End With
With Data
ReDim .Data(0)
End With
With HeaderInfo
.lngFileCount = UBound(FilenameList)
If .lngFileCount = 0 Then
Exit Sub '\\ no files
Else
End If
'\\ Validate each of the files (make sure they exist)
For lngCounter = 0 To .lngFileCount
If lngCounter > 0 Then
If Dir$(FilenameList(lngCounter)) = "" Then
'\\ Move each of the filenames above this one to the one lower
For lngCounter2 = lngCounter To .lngFileCount - 1
FilenameList(lngCounter2) = FilenameList(lngCounter2 + 1)
Next lngCounter2
'\\ Resize the array
.lngFileCount = .lngFileCount - 1
ReDim Preserve FilenameList(.lngFileCount)
End If
End If
Next lngCounter
'\\ Create the rest of the header
ReDim .FilenameLens(.lngFileCount)
ReDim .Filenames(.lngFileCount)
ReDim .DataLen(.lngFileCount)
For lngCounter = 0 To .lngFileCount
If lngCounter > 0 Then
.Filenames(lngCounter) = Dir$(FilenameList(lngCounter))
.FilenameLens(lngCounter) = Len(.Filenames(lngCounter))
.DataLen(lngCounter) = FileLen(FilenameList(lngCounter))
End If
Next lngCounter
End With
'\\ Prepare the data arrays
With Data
ReDim .Data(HeaderInfo.lngFileCount)
For lngCounter = 0 To HeaderInfo.lngFileCount
If lngCounter > 0 Then
.Data(lngCounter) = Space$(HeaderInfo.DataLen(lngCounter))
End If
Next lngCounter
End With
'\\ Load data into the arrays
hFile = FreeFile()
For lngCounter = 0 To HeaderInfo.lngFileCount
If lngCounter > 0 Then
Open FilenameList(lngCounter) For Binary Access Read As hFile
Get hFile, 1, Data.Data(lngCounter)
Close hFile
HeaderInfo.FilenameLens(lngCounter) = Len(Data.Data(lngCounter))
End If
Next lngCounter
'\\ Encrypt if enabled
If blnEncrypt Then
For lngCounter = 0 To HeaderInfo.lngFileCount
If lngCounter > 0 Then
strEncrypt = ""
For dblCounter = 1 To Len(Data.Data(lngCounter))
If dblCounter = 1 Then
strTemp = Left$(Data.Data(lngCounter), 1)
ElseIf dblCounter = Len(Data.Data(lngCounter)) Then
strTemp = Right$(Data.Data(lngCounter), 1)
Else
strTemp = Mid$(Data.Data(lngCounter), dblCounter, 1)
End If
strEncrypt = strEncrypt & Chr$(((Asc(strTemp) + bytEncryptShift)) Mod 256)
Next dblCounter
Data.Data(lngCounter) = strEncrypt
End If
Next lngCounter
End If
'\\ Save the whole thing into the specified file
If Not LCase(Right$(strFilename, 4)) = LCase(DEFAULT_EXTENSION) Then
strFilename = strFilename & DEFAULT_EXTENSION
End If
Open strFilename For Binary Access Write As hFile
Put hFile, 1, VersionInfo
Put hFile, , HeaderInfo
Put hFile, , Data
Close hFile
End Sub
That's from a class that I wrote to handle exactly this type of thing. It's not nearly as complicated as it looks; read through it and you'll see that much of it is checking compatibility. Note that some If-Then statements are empty, because I removed a reference to a debugging class (for example, when extracting a file from a different version that created it, a warning would be put in my debug log so I'd know why the program crashed).
Hopefully this gets you on your feet 
-Amrazek
|
__________________
If I put my two cents in and get a penny for my thoughts, where does my other penny go?
If quitters never win, and winners never quit, who came up with "Quit while you're ahead?"
|

06-15-2004, 02:05 PM
|
|
Centurion
|
|
Join Date: Feb 2003
Posts: 150
|
|
[Previous post was too long to include these]
Code:
'============================================================================================='
' Public Function: ExtractFile
' Purpose: Extracts a watermarked file from a resource pack.
'============================================================================================='
Public Function ExtractFile(ByVal strResourcePath As String, ByVal strFilename As String, ByVal strExtractDir As String, Optional blnDecrypt As Boolean, Optional bytBitShift As Byte = 128) As Boolean
Dim VersionInfo As WATERMARK_VERSION
Dim HeaderInfo As WATERMARK_HEADER
Dim Data As WATERMARK_DATA
Dim lngCounter As Long '\\ A counting variable
Dim dblCounter As Double '\\ A large counting variable
Dim hFile As Long
Dim lngTemp As Long '\\ Temporary variable
Dim strTemp As String '\\ Temporary string variable
Dim strDecrypt As String '\\ String to hold decrypted values
ExtractFile = False
'\\ Ensure that the resource file exists
If Not Dir$(strResourcePath) <> "" Then
Exit Function
End If
'\\ Load the version info
hFile = FreeFile()
Open strResourcePath For Binary Access Read As hFile
Get hFile, 1, VersionInfo
Close hFile
'\\ Compare versions
If VersionInfo.GUID <> WATERMARK_GUID Then
Exit Function
End If
If VersionInfo.MajorDLL <> App.Major Or _
VersionInfo.MinorDLL <> App.Minor Or _
VersionInfo.RevisionDLL <> App.Revision Then
End If
'\\ Load the Header
Open strResourcePath For Binary Access Read As hFile
Get hFile, 1, VersionInfo
Get hFile, , lngTemp
Close hFile
With HeaderInfo
ReDim .DataLen(0)
ReDim .FilenameLens(0)
ReDim .Filenames(0)
ReDim .DataLen(lngTemp)
ReDim .FilenameLens(lngTemp)
ReDim .Filenames(lngTemp)
End With
Open strResourcePath For Binary Access Read As hFile
Get hFile, 1, VersionInfo
Get hFile, , HeaderInfo
'\\ Load the Data
With Data
ReDim .Data(HeaderInfo.lngFileCount)
For lngCounter = 0 To HeaderInfo.lngFileCount
If lngCounter > 0 Then
.Data(lngCounter) = Space$(HeaderInfo.DataLen(lngCounter))
End If
Next lngCounter
End With
Get hFile, , Data
Close hFile
'\\ Find the file we're looking for
For lngCounter = 0 To HeaderInfo.lngFileCount
If lngCounter > 0 Then
If LCase(HeaderInfo.Filenames(lngCounter)) = LCase(strFilename) Then
lngTemp = lngCounter
Exit For
End If
End If
Next lngCounter
'\\ Decrypt if necessary
If blnDecrypt Then
strDecrypt = ""
With Data
For dblCounter = 1 To Len(.Data(lngTemp))
If dblCounter = 1 Then
strTemp = Left$(.Data(lngTemp), 1)
ElseIf dblCounter = Len(.Data(lngTemp)) Then
strTemp = Right$(.Data(lngTemp), 1)
Else
strTemp = Mid$(.Data(lngTemp), dblCounter, 1)
End If
lngCounter = ((Asc(strTemp) - bytBitShift) Mod 256)
If lngCounter < 0 Then lngCounter = 256 - Abs(lngCounter)
strDecrypt = strDecrypt & Chr$(lngCounter)
Next dblCounter
.Data(lngTemp) = strDecrypt
End With
End If
'\\ Extract that file
If Right$(strExtractDir, 1) <> "\" Then strExtractDir = strExtractDir & "\"
Open strExtractDir & HeaderInfo.Filenames(lngTemp) For Binary Access Write As hFile
Put hFile, 1, Data.Data(lngTemp)
Close hFile
ExtractFile = True
End Function
'============================================================================================='
' Public Function: GetFileCount
' Purpose: Returns the number of files in a resource file.
'============================================================================================='
Public Function GetFileCount(ByVal strResourcePath As String)
Dim VersionInfo As WATERMARK_VERSION
Dim HeaderInfo As WATERMARK_HEADER
Dim lngCounter As Long '\\ A counting variable
Dim dblCounter As Double '\\ A large counting variable
Dim hFile As Long
Dim lngTemp As Long '\\ Temporary variable
Dim strTemp As String '\\ Temporary string variable
Dim strDecrypt As String '\\ String to hold decrypted values
GetFileCount = 0
'\\ Ensure that the resource file exists
If Not Dir$(strResourcePath) <> "" Then
Exit Function
End If
'\\ Load the version info
hFile = FreeFile()
Open strResourcePath For Binary Access Read As hFile
Get hFile, 1, VersionInfo
Close hFile
'\\ Compare versions
If VersionInfo.GUID <> WATERMARK_GUID Then
Exit Function
End If
If VersionInfo.MajorDLL <> App.Major Or _
VersionInfo.MinorDLL <> App.Minor Or _
VersionInfo.RevisionDLL <> App.Revision Then
End If
'\\ Load the Header
Open strResourcePath For Binary Access Read As hFile
Get hFile, 1, VersionInfo
Get hFile, , lngTemp
Close hFile
'\\ Return the file count
GetFileCount = lngTemp
End Function
Note that in SaveFile, Filenames() is asking for a list of filenames (valid, full paths) that you want to add to the resource file. You'll have to add your own function to add single files.
-Amrazek
|
__________________
If I put my two cents in and get a penny for my thoughts, where does my other penny go?
If quitters never win, and winners never quit, who came up with "Quit while you're ahead?"
|

06-16-2004, 01:26 AM
|
|
Junior Contributor
|
|
Join Date: Mar 2003
Posts: 238
|
|
you could store each pixel of the images manually into an array and enter that into a dll 
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|