Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
cpjamloki
Level 7

robitmap in legacy device

Facing problem in legacy device in case of robitmap.
in case of nonlegacy device below code is working good. but for legacy device(version 3.0) robitmap object giving problem.

first time
 m.bMapImage = createobject("roBitmap", getting single images here)
m.bitmapimage creating robitmap object for first image.
but next time for second image(loop increment by 1) it's not creating object. and jump in else part
print "BMAPIMAGE_IS_INVALID "
.

is it legacy device problem for robitmap?


for j=0 to 9 step 1

if(m.bMapImage<>invalid)
m.bMapImage.clear(m.white)
end if

m.bMapImage = createobject("roBitmap", getting single images here)

m.msgport1 = CreateObject("roMessagePort")
if isLegacyDevice()
m.screen.SetPort(m.msgport1)
else
m.screen.SetMessagePort(m.msgport1)
end if
codes = bslUniversalControlEventCodes()
msg1=wait(1700, m.msgport1)

if m.bMapImage <> invalid
m.screen.DrawScaledObject(FIX(marginX), FIX(marginY), imageWidth / m.bMapImage.GetWidth(), imageHeight / m.bMapImage.GetHeight(),m.bMapImage)

else
print "BMAPIMAGE_IS_INVALID "

end if

end for



any suggestion would be thankful.
0 Kudos
3 Replies
Rek
Level 7

Re: robitmap in legacy device

It could be you're running out of video memory. When you run out of video memory, a call to createObject("roBitmap", ...) will just return invalid.

Each iteration of the for-loop, you're allocating a new bitmap, but the old one(s) don't get de-allocated unless you call screen.finish() or screen.SwapBuffers() (depends on if your screen is single or double buffered).

You can verify the video memory usage by telnetting to your roku on port 8080, then running the command: r2d2_bitmaps
0 Kudos
RokuMarkn
Level 7

Re: robitmap in legacy device

A couple small comments on your code:
1. I'm not sure exactly what this code is supposed to be doing, but the lack of SwapBuffers/Finish is a major omission. If this code displays anything on the screen it's accidental.
2.You can use SetPort on non-legacy devices. You don't need to test for legacy and call SetMessagePort.
3. The clear at the top of the loop doesn't do anything useful since you destroy the object in the next line. Setting m.bMapImage = invalid would be more appropriate.

--Mark
0 Kudos
cpjamloki
Level 7

Re: robitmap in legacy device

thanx Rek . you are right.
0 Kudos