Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
BinaryMadman
Visitor

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
0 Kudos
4 REPLIES 4
renojim
Community Streaming Expert

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

Try adding a screen.Finish() call.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
BinaryMadman
Visitor

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

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.
0 Kudos
renojim
Community Streaming Expert

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

Hmm... How about bigbm.finish()?

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

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
BinaryMadman
Visitor

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

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!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.