How do i scroll an image and fit to screen width?

I want to set an image to fit the screen width and is able to scroll the image by using the ‘up’ and ‘down’ keys on the remote. I found this example code for scrolling a bitmap but it just displays the black screen. When i press the Home button on the remote it briefly displays the image for a split second but then the program exits and goes back to the Roku menu. What am i missing or doing wrong with this example code? The only thing i’ve changed from the original code is the image path.

function main()
    black=&hFF      'RGBA
    screen=CreateObject("roScreen")
    compositor=CreateObject("roCompositor")
    compositor.SetDrawTo(screen, black)
    bigbm=CreateObject("roBitmap","pkg:/images/Image1.jpg")
    region=CreateObject("roRegion", bigbm, 0, 0, 1280, 720)
    region.SetWrap(true)
    view_sprite=compositor.NewSprite(0, 0, region)
    compositor.draw()
    msgport = CreateObject("roMessagePort")
    screen.SetMessagePort(msgport)
    codes = bslUniversalControlEventCodes()
    
    while true
        msg=wait(0, msgport) ' wait for a button
        if type(msg)="roUniversalControlEvent" then 
            if msg.GetInt()=codes.BUTTON_UP_PRESSED then 
                Zip(view_sprite, compositor, 0,-4) 'up
            else if msg.GetInt()=codes.BUTTON_DOWN_PRESSED then  
                Zip(view_sprite, compositor, 0,+4) ' down
            else if msg.GetInt()=codes.BUTTON_RIGHT_PRESSED then 
                Zip(view_sprite, compositor, +4,0) ' right
            else if msg.GetInt()=codes.BUTTON_LEFT_PRESSED then 
                Zip(view_sprite, compositor, -4, 0) ' left
            else if msg.GetInt() = codes.BUTTON_BACK_PRESSED ' back button
                exit while
            end if
        end if
    end while
end function

function Zip(view_sprite, compositor, xd, yd)
    for x=1 to 60
        view_sprite.OffsetRegion(xd, yd, 0, 0) 
        compositor.draw()
    end for
end function

Try adding a screen.Finish() call.

-JT

Hmm…nope, adding screen.Finish() does not seem to fix it. It still doesn’t show the image until after the user presses the Home key to close the channel.

Hmm… How about bigbm.finish()?

I can’t even load the scroll example because the package size is too big. :roll:

-JT

bigbm.Finish() did not work but i took your advice of looking at the scrolling example code and i modified it to work with my project. It worked and scrolled as it was supposed to. Now i just need to modify it further so it works the way i want it to. Thanks, renojim!