BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2012
09:44 PM
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
4 REPLIES 4
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2012
10:24 PM
Re: How do i scroll an image and fit to screen width?
Try adding a screen.Finish() call.
-JT
-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.
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.
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2012
11:00 PM
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.
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2012
11:46 PM
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
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.
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.
BinaryMadman
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2012
12:42 AM
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!