ScreenSaver

Blitz3D Forums/Blitz3D Beginners Area/ScreenSaver

Terry B.(Posted 2007) [#1]
How do you make a B3d exe file into a screensaver?


DREAM(Posted 2007) [#2]
i made a screensaver by taking off the .exe and renaming to .scr

i also didnt have any interface stuff for windows to use, and i also had to store all the images internally in a data array, it seems it didnt like loading images, it was a lot of trial and error......


PowerPC603(Posted 2007) [#3]
There was a previous topic about screensavers:
http://www.blitzbasic.com/Community/posts.php?topic=60409#673566

A screensaver executable is just the same as a standard executable, it only has a different file extension (.scr instead of .exe), that's all.


jfk EO-11110(Posted 2007) [#4]
There's a further slight diffrence: It won't find the media files since it thinks it was started from c:/ (as far as I remember). You have to add this line:

changedir systemproperty("Appdir")
Now it will act as an ordinary EXE.

The SCR file must be copied to the system folder, then it will be listed automaticly in the screensaver dialog.

But even now you'd need to copy the media files to the system folder too, that's no good. Better use a Packer like Molebox, or store the media in DATA space, as PowerPC603 suggested.


Buggy(Posted 2007) [#5]
How do you store media in a DATA space?


PowerPC603(Posted 2007) [#6]
Use Visual Blitz, it can read images and store them into data-statements.
It also creates code to retreive the data from the data-statements so you can transform the data-statements into a Blitz-image for further use.

It also transforms files into data-statements and generates code to recreate the file from those data-statements.

Other files, like sounds, 3D-models, textures, ..., you can use a datapacker like jfk mentioned, I never tried such tools so I cannot say which one to use or which one is best.

If you cannot afford Visual Blitz, you can use the demo, but it cannot save files and also cannot compile the executables.
But you can generate the data-statements (I think) from images (JPG, BMP, ...), highlight all code that Visual Blitz generates, copy and paste that code into the Blitz3D IDE and use it from there.

You can check it out here:
http://www.blitzbasic.com/toolbox/toolbox.php?tool=4


Loktar(Posted 2007) [#7]
What I do for all of my screensavers is have it install them in the Program Files directory and write a key to the registry with the path that it was installed to. Then the screensaver portion thats run from system32 (a vb app) looks for the path and calls the actual exe, then the exe changes its path based on the value in the registry.


DREAM(Posted 2007) [#8]
I didnt do all the fancy stuff with registry keys and changing directory, although this probably is the best way to go if you are going to make lots of them...

I store images into arrays (eg dim picdata(x,y)) then read the colour data into them for each pixel

this is what i did, not perfect coding but it worked...

Graphics 800,600

Global butt1=LoadAnimImage("bug_butterfly01.png",32,32,0,20)
Global butterfly


Dim imagefr(20,31,31)


For i=0 To 19
SetBuffer ImageBuffer(butt1,i)
	For x=0 To 31
		For y=0 To 31
			If y=0 Or y=16
				li$="Data "
			EndIf
			GetColor x,y
			rgb=MakeRGB(ColorRed(),ColorGreen(),ColorBlue())
			imagefr(i,x,y)=rgb
			If y=15 Or y=31
				li$=li$+Str(rgb)
				DebugLog li$
			Else
				li$=li$+Str(rgb)+","	
			EndIf
		Next
	Next
Next
makebutterfly()
i=0
SetBuffer BackBuffer()
Repeat
Cls
	DrawImage butterfly,100,100,i
	If KeyHit(208) Then i=i+1
	If KeyHit(200) Then i=i-1
	If i>19 Then i=0
	If i<0 Then i=19
	Color 250,180,0
	Text 200,200,i
Flip
Until KeyHit(1)
End

Function makebutterfly()
	butterfly=CreateImage (32,32,20)
	For i=0 To 19
		SetBuffer ImageBuffer(butterfly,i)
		For x=0 To 31
			For y=0 To 31
				rgb=imagefr(i,x,y)
				Color ExtractRed(rgb),ExtractGreen(rgb),ExtractBlue(rgb)
				Plot x,y
			Next 
		Next
	Next
	SetBuffer BackBuffer()
End Function


Function MakeRGB(r,g,b)
	r=r Shl 16				; Move red component two bytes to the left
	g=g Shl 8				; Move green component one byte to the left
	result=r+g+b			; Add them up
	Return result			; And send the result right back at ya'
End Function

Function ExtractRed(rgb)
	result = rgb And 16711680	; 00FF0000 in Hex. Anding with this eliminates all non-red values.
	result=result Shr 16		; Move red component two bytes to the right
	Return result				; And send the result right back at ya'
End Function

Function ExtractGreen(rgb)
	result = rgb And 65280  	; 0000FF00 in Hex. Anding with this eliminates all non-green values.
	result=result Shr 8			; Move green component one byte to the right
	Return result				; And send the result right back at ya'

End Function

Function ExtractBlue(rgb)
	result = rgb And 255    	; 000000FF in Hex. Andin with this eliminates all non-blue values.
	Return result				; And send the result right back at ya'
End Function


the ExtractBlue(rgb) , ExtractRed(rgb) , ExtractGreen(rgb) and makergb(rgb) functions were from the archive, i have forgotten who wrote them or the post, sorry....

you might make sense of it...i then selected all the debuglog and copy pasted it into a bb file as a collection of data staements...


jfk EO-11110(Posted 2007) [#9]
a simple solution to convert a picture to a data-segment would also be:
f$="mypic.bmp"
pic=loadimage(f$)
wr=writefile("temp_data.bb")
writeline wr,"."+replace$(f$,".","_")
writeline wr,"Data "+imagewidth(pic)
writeline wr,"Data "+imageheight(pic)
setbuffer imagebuffer(pic)
lockbuffer()
for j=0 to imageheight(pic)-1
 z$="Data "
 for i=0 to imagewidth(pic)-1
 rgb=readpixelfast(i,j) and $ffffff
  if i<(imagewidth(pic)-1)
   z$=z$+"$"+hex$(rgb)+","
  else
   z$=z$+"$"+hex$(rgb)
  endif
 next
 writeline wr,z$
next
unlockbuffer()
closefile wr
end

(just typed, there may be typos)
Now there should be a file named temp_data.bb. You can copy paste it to your program, or use INCLUDE. To load such an image from this Data segement, you could do something like:

restore mypic_bmp
read w
read h
pic=createimage(w,h)
setbuffer imagebuffer(pic)
lockbuffer()
for j=0 to h-1
 for i=0 to w-1
  read rgb
  writepixelfast i,j,rgb
 next
next
unlockbuffer()
setbuffer backbuffer()



Boiled Sweets(Posted 2007) [#10]
I just pack all my media using the free Pak library then install the data file to windows\system32.