Dual Screen screen saver
Dual Screen screen saver
Ok here's a nice easy one (I Hope?)
I want to be able to load images from a specified directory in a random order (I have the random order bit sussed)
Also the pictures must be stretched to fit the screen if possible and......
I want the picture to load onto my main screen
I want to display some text/data/another picture on the other screen
(I hope this is making sense?)
Help! I have tried drinking a lot of beer tonight for inspiration but all I have is a full bladder and less braincells 8O
I want to be able to load images from a specified directory in a random order (I have the random order bit sussed)
Also the pictures must be stretched to fit the screen if possible and......
I want the picture to load onto my main screen
I want to display some text/data/another picture on the other screen
(I hope this is making sense?)
Help! I have tried drinking a lot of beer tonight for inspiration but all I have is a full bladder and less braincells 8O
This kind of question, is difficult to reply to. Because you are practicaly asking for a full program. And we can't tell very well what you know and what you don't.
If you are new to programing, It's best to go little by little. Start by loading an image (for what you what to do, seems a better option than sprite) and display it, then try to fit it etc etc...
And go searching/asking in the forums as you run into trouble. Post some code, so we can see better what the problem is.
As for the dual screen, I have no idea, not lucky enough to have 2 monitors
Press F1 and have a look at 2DDrawing, Image, ImagePlugin, FileSystem, and don't forget to look at ClearScreen() and FlipBuffers() in Sprites.
Good luck, and wellcome to this wonderfull coding language.
If you are new to programing, It's best to go little by little. Start by loading an image (for what you what to do, seems a better option than sprite) and display it, then try to fit it etc etc...
And go searching/asking in the forums as you run into trouble. Post some code, so we can see better what the problem is.
As for the dual screen, I have no idea, not lucky enough to have 2 monitors

Press F1 and have a look at 2DDrawing, Image, ImagePlugin, FileSystem, and don't forget to look at ClearScreen() and FlipBuffers() in Sprites.
Good luck, and wellcome to this wonderfull coding language.
two screens and one screen are, from a certain point of view, the same thing, do a search on the board, i've posted some code for multiple monitors in the past, you must have overlooked it 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I think I'm stuck?
Ok I've got my pictures loading ok but I'm not sure if I'm doing the delay between pictures properl : Delay(3000)
Also the program dosn't always close nicely some times there's an error :
Error at line 28 : The specified output is null (0 value)
Line 28 -> If StartDrawing(ScreenOutput())
And why does the desktop wallpaper disappear after running this??
Also the program dosn't always close nicely some times there's an error :
Error at line 28 : The specified output is null (0 value)
Line 28 -> If StartDrawing(ScreenOutput())
And why does the desktop wallpaper disappear after running this??
Code: Select all
PictureDirectory.s="D:\My Pictures\Wallpaper Cars\"
UseEC_OLEImageDecoder()
Dim Picture.s(1000)
If ExamineDirectory(1,PictureDirectory,"*.*")
Repeat
FileType = NextDirectoryEntry()
If FileType=1
Picture(Counter) = DirectoryEntryName()
Counter+1
EndIf
Until FileType = 0
EndIf
If InitSprite()And InitKeyboard()And InitMouse()
If OpenScreen(1280, 1024,32, "")
Repeat
; Choose random picture and Load into memory -------------------------------------------------------------------------------------------------
RandomPicture.s = PictureDirectory + Picture(Random(counter-1))
ImageID = LoadImage(0, RandomPicture)
; Centre the picture -----------------------------------------------------------------------------------------------------------------------------------------
PictureWidth =ImageWidth()
PictureHeight =ImageHeight()
ImageXPos=(1280/2)-(PictureWidth/2)
ImageYPos=(1024/2)-(PictureHeight/2)
; Display the Picture ----------------------------------------------------------------------------------------------------------------------------------------
If StartDrawing(ScreenOutput())
Box(0, 0, 1280, 1024,0)
If ImageID <>0
DrawImage(ImageID, ImageXPos,ImageYPos)
EndIf
StopDrawing()
FlipBuffers(1)
EndIf
; Check for a Keypress/Mouse etc... --------------------------------------------------------------------------------------------------------------------
Delay (3000)
ExamineKeyboard()
ExamineMouse()
Until KeyboardPushed(#PB_Key_All) Or MouseDeltaX() <> 0 Or MouseDeltaY() <> 0 Or MouseWheel() <> 0 Or MouseButton(1) <> 0 Or MouseButton(2) <> 0 Or MouseButton(3) <> 0
EndIf
EndIf
End
Jon,
I made some adjutments in your code. The delay is good with 3 seconds. On my own, I would use maybe just a bit longer (4-5 seconds), but it depends on how much images you have to display : more, the delay is good, less enhance the delay to a higher time.
BTW, I changed the image drawing and the delay logic to make it as accurate as possible without to consume CPU (look the different lines of code).
Also I placed a linked list instead of an array, which makes the coding maybe more easy to understand. Also you have not to take care about the images amount you have in the directory you parse.
Now, if you want to add any drawings in your loop, just place some more lines of code in the main loop, inside a StartDrawing() / StopDrawing() pattern.
I finally placed screen's dimensions in variables, and added an image resize calculation to apply resizing with constaint proportions.
Just before to run this again, change directory and screen size to yours. Maybe you will add one thing, is to check the screen about its depth, because people having screens with lower depth than 32 will not run this program.
I made some adjutments in your code. The delay is good with 3 seconds. On my own, I would use maybe just a bit longer (4-5 seconds), but it depends on how much images you have to display : more, the delay is good, less enhance the delay to a higher time.
BTW, I changed the image drawing and the delay logic to make it as accurate as possible without to consume CPU (look the different lines of code).
Also I placed a linked list instead of an array, which makes the coding maybe more easy to understand. Also you have not to take care about the images amount you have in the directory you parse.
Now, if you want to add any drawings in your loop, just place some more lines of code in the main loop, inside a StartDrawing() / StopDrawing() pattern.
I finally placed screen's dimensions in variables, and added an image resize calculation to apply resizing with constaint proportions.
Just before to run this again, change directory and screen size to yours. Maybe you will add one thing, is to check the screen about its depth, because people having screens with lower depth than 32 will not run this program.
Code: Select all
NewList Picture.s()
PictureDirectory.s = "C:\RECUP\images\Space others\"
UseEC_OLEImageDecoder()
If ExamineDirectory(1, PictureDirectory, "*.*")
Repeat
FileType = NextDirectoryEntry()
If FileType = 1
AddElement(Picture())
Picture() = DirectoryEntryName()
Counter + 1
EndIf
Until FileType = 0
EndIf
ScreenXSize = GetSystemMetrics_(#SM_CXSCREEN)
ScreenYSize = GetSystemMetrics_(#SM_CYSCREEN)
ScreenDepth = 32
If InitSprite() And InitKeyboard() And InitMouse()
If OpenScreen(ScreenXSize, ScreenYSize, ScreenDepth, "Random Images")
Repeat
FlipBuffers()
ClearScreen(0, 0, 0)
If StartDrawing(ScreenOutput())
Box(0, 0, ScreenXSize, ScreenYSize,0)
If ImageID <> 0
DrawImage(ImageID, ImageXPos, ImageYPos)
EndIf
StopDrawing()
EndIf
; Check for a Keypress/Mouse etc... --------------------------------------------------------------------------------------------------------------------
If ElapsedMilliseconds() - Delay => 3000
Delay = ElapsedMilliseconds()
; Choose random picture and Load into memory -------------------------------------------------------------------------------------------------
SelectElement(Picture(), Random(Counter - 1))
RandomPicture.s = PictureDirectory + Picture()
If ImageID
FreeImage(0)
EndIf
ImageID = LoadImage(0, RandomPicture)
; Centre the picture -----------------------------------------------------------------------------------------------------------------------------------------
PictureWidth = ImageWidth()
PictureHeight = ImageHeight()
kx.f = PictureWidth / ScreenXSize
ky.f = PictureHeight / ScreenYSize
kx.f = ScreenXSize / PictureWidth
ky.f = ScreenYSize / PictureHeight
If kx < ky
PictureWidth = PictureWidth * kx
PictureHeight = PictureHeight * kx
Else
PictureWidth = PictureWidth * ky
PictureHeight = PictureHeight * ky
EndIf
ImageID = ResizeImage(0, PictureWidth, PictureHeight)
ImageXPos = (ScreenXSize - PictureWidth) / 2
ImageYPos = (ScreenYSize - PictureHeight) / 2
; Display the Picture ----------------------------------------------------------------------------------------------------------------------------------------
EndIf
ExamineKeyboard()
ExamineMouse()
If KeyboardPushed(#PB_Key_All)
Quit = #TRUE
EndIf
If MouseDeltaX() <> 0 Or MouseDeltaY() <> 0 Or MouseWheel() <> 0 Or MouseButton(1) <> 0 Or MouseButton(2) <> 0
Quit = #TRUE
EndIf
Delay(5)
Until Quit
CloseScreen()
EndIf
EndIf
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Thank you for the code adjustment, much appreciatedfweil wrote:Jon,
I made some adjutments in your code. The delay is good with 3 seconds. On my own, I would use maybe just a bit longer (4-5 seconds), but it depends on how much images you have to display : more, the delay is good, less enhance the delay to a higher time.

Yes I've looked over the changes and made sense of them. ->BTW, I changed the image drawing and the delay logic to make it as accurate as possible without to consume CPU (look the different lines of code).

Now that really is me being totally lazyAlso I placed a linked list instead of an array, which makes the coding maybe more easy to understand. Also you have not to take care about the images amount you have in the directory you parse.

Now, not sure If Ive got the right idea here, do you mean other 2d drawing operations? eg. text etc... or X2D_Text(x.l, y.l, text.s[, angle.l]) (which I am toatally sure is a dud command, must report as a bug?)Now, if you want to add any drawings in your loop, just place some more lines of code in the main loop, inside a StartDrawing() / StopDrawing() pattern.
Now that resize is just groovy cheers !!
I finally placed screen's dimensions in variables, and added an image resize calculation to apply resizing with constaint proportions.
well I was just going to make sure it worked on my pc really, but, I spose it's just good practice to have checks in there (I should change my name to lazy coder, heh heh]Maybe you will add one thing, is to check the screen about its depth, because people having screens with lower depth than 32 will not run this program.
1 Question, I had a quick search on the board but nothing really satisfied me, what I want to know is can I use RED BLUE GREEN or Gamma commands etc to do a simple fade in/out? Or is it just a little bit more complicated.
Jon,
You may use ChangeGamma() for fade in/out AFAIK, but I can't test it well on my PC. According to documentation, you would have to code first :
ChangeGamma(0, 0, 0, 1) just after OpenScreen
and
ChangeGamma(RedValue, GreenValue, BlueValue, 0)
just after the ClearScreen()
About adding 2D drawings, you may any kind of drawing, either text or points, etc,inside the StartDrawing() / StopDrawing() part.
KRgrds
You may use ChangeGamma() for fade in/out AFAIK, but I can't test it well on my PC. According to documentation, you would have to code first :
ChangeGamma(0, 0, 0, 1) just after OpenScreen
and
ChangeGamma(RedValue, GreenValue, BlueValue, 0)
just after the ClearScreen()
About adding 2D drawings, you may any kind of drawing, either text or points, etc,inside the StartDrawing() / StopDrawing() part.
KRgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Righto, I've managed to get my pics to fade in then out, I just included a small bit of the code (See earlier post)
Is this the best way to acheive a fadein/out? It's stuffing up the mouse/kboard detection to stop the screen saver?
Code: Select all
If OpenScreen(ScreenXSize, ScreenYSize, ScreenDepth, "Random Images")
ChangeGamma(0, 0, 0, 1)
Repeat
For FadeOut=255 To 0 Step -5
ChangeGamma( FadeOut, FadeOut, FadeOut,0)
Next
FlipBuffers()
ClearScreen(0, 0, 0)
For FadeIn=0 To 255 Step 5
ChangeGamma(FadeIn,FadeIn,FadeIn,0)
Next
This way to fade in/out is well if you are fading the whole screen.
For fading sprites an appropriate set of commands exists.
You may use both keyboard / mouse events for stopping the screen saver.
I guess it is also possible to eventually hide a screen saver if some CPU is consumed by other processes, but it is more difficult to code. Also when a screen saver runs, it often consume much CPU itself ...
For fading sprites an appropriate set of commands exists.
You may use both keyboard / mouse events for stopping the screen saver.
I guess it is also possible to eventually hide a screen saver if some CPU is consumed by other processes, but it is more difficult to code. Also when a screen saver runs, it often consume much CPU itself ...
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.