Enable and Disable a Control


Two methods to hide bitmaps from users.

'Hide bmps from your users by disguising them as
'files of another type.
'To make this doubly secure, remove the first two
'bytes of bmp data and save the file.  When
'your program needs the bmp, open the oddball
'file, add the "BM" to the beginning, and write
'the file to disk, then loadbmp.  Kill the bmp
'file after it is loaded and the user will
'never see it.

nomainwin
filedialog "Open","*.bmp",bmp$
if bmp$="" then end

'open bmp and get data into string var:
open bmp$ for input as #b
bmpdata$=input$(#b,lof(#b))
datasize=lof(#b)
close #b

'remove first two chars:
bmpdata$=right$(bmpdata$,datasize-2)

'write file with your choice of oddball extension:
open "test.wow" for output as #t
print #t, bmpdata$
close #t


'open file, read data into string var:
open "test.wow" for input as #w
newdata$=input$(#w,lof(#w))
close #w

'now, write a proper bmp file:
'first, add "BM" to beginning of data:
newdata$="BM"+newdata$
open "test.bmp" for output as #s
print #s, newdata$
close #s

'now load this bmp:
loadbmp "hey","test.bmp"
open "Wow!" for graphics as #1
print #1, "trapclose [quit]"
print #1, "down;drawbmp hey 0 0;flush"
unloadbmp "hey"
kill "test.bmp"
wait

[quit]
close #1:end

******************************
'Hide bmps from your users by disguising them as
'files of another type.
'To make this doubly secure, alter the first two
'bytes of bmp data and save the file.  When
'your program needs the bmp, open the oddball
'file, change the first two bytes to "BM" .
'Change bytes back afterward.

nomainwin
filedialog "Open","*.bmp",bmp$
if bmp$="" then end

'open bmp and copy to dummy file:
open bmp$ for input as #b
bmpdata$=input$(#b,lof(#b))
close #b

'write file with your choice of oddball extension:
open "test.wow" for output as #t
print #t, bmpdata$
close #t


'open file, modify first two bytes
open "test.wow" for binary as #w
print #w, "AB"
close #w

'now, change first two bytes to "BM":
open "test.wow" for binary as #s
print #s, "BM"
close #s

'now load this bmp:
loadbmp "hey","test.wow"
open "Wow!" for graphics as #1
print #1, "trapclose [quit]"
print #1, "down;drawbmp hey 0 0;flush"
unloadbmp "hey"

'open file, modify first two bytes
open "test.wow" for binary as #w
print #w, "AB"
close #w

wait

[quit]
close #1:end


Home

Source Code

Utilities

Internet

Games

Graphics

Media Demos

Snippets

DLL's

API Resources

Freeware

LB 4 Companion

Mastering LB 3

LB Workshop

Game Workshop

Links

Index