[SOLVED]Scrolling with get and put

New to FreeBASIC? Post your questions here.
Post Reply
DjPoke
Posts: 6
Joined: Dec 02, 2005 1:33
Location: Corsica (France)

[SOLVED]Scrolling with get and put

Post by DjPoke »

Hello ! :)

I'm trying to make scroll a portion of my screen, but all the screen is cleared when i call my function.
I use screen 19 in 32 bits depth.
Any idea ?

Code: Select all

' scrolling
Sub WB_Scroll(x1 As integer, y1 as integer, x2 as integer, y2 as integer, x3 As integer, y3 as integer)
    Dim tempImg As fb.Image Ptr = ImageCreate(x2 - x1 + 1, y2 - y1 + 1, RGB(0, 0, 0), 32)

    ' get the image
    Get (x1, y1)-(x2, y2), tempImg

    ' lock the screen and put it
    ScreenLock
        Cls
        Put (x3, y3), tempImg
    ScreenUnlock
    
    ' destroy the image
    ImageDestroy(tempImg)
End Sub
Last edited by DjPoke on Nov 06, 2022 19:02, edited 1 time in total.
DjPoke
Posts: 6
Joined: Dec 02, 2005 1:33
Location: Corsica (France)

Re: Scrolling with get and put

Post by DjPoke »

I've discovered that 'pset' is needed to replace pixels.

Code: Select all

Put (x1, y1), tempImg, pset
I write text on the screen and try to scroll, but i get only a black screen.
If i remove the rgb color parameter in the image creation, all the screen become pink.

May be because i use ScreenSet before ? Are Get and Put commands affected by ScreenSet ?
DjPoke
Posts: 6
Joined: Dec 02, 2005 1:33
Location: Corsica (France)

Re: Scrolling with get and put

Post by DjPoke »

Ok... After a lot of tests, i think that the 'Get' command don't get anything in the screen if the selected area is too big.
Imortis
Moderator
Posts: 1923
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: [SOLVED]Scrolling with get and put

Post by Imortis »

You should look into what the CLS command does. Its entire purpose is to clear the screen. You probably just need to remove that command.
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: [SOLVED]Scrolling with get and put

Post by angros47 »

I cannot tell for sure, without seeing the whole code, but I think you try to scroll the whole screen, with your code. The command GET has to acquire an area that is completely inside the visible screen, otherwise it will have no effect. So, if, for example, your screen has a resolution of 640*480, and you do something like WB_Scroll(1,0,641,0,0,0) to perform a scroll to left, it will fail because you will attempt to GET outside of the visible area

Also, do you set the screen mode with Screen or with ScreenRes? (remember that Screen sets 8 bit mode, and so GET and PUT will expect an 8 bit buffer)
Post Reply