I've tried de-allocating just about everything that can be de-allocated. I just tried to make it more simple by using an array of roRegions and it looks like it can only do 4 items before saying the bitmap 'bmImage' was unable to be created. I find that to be a bit odd that it would stop working that early into it.
UPDATED CODE:
' ******
' ****** Scroll a view around a large plane, double buffered
' ******
Library "v30/bslCore.brs"
Function IsHD()
di = CreateObject("roDeviceInfo")
if di.GetDisplayType() = "HDTV" then return true
return false
End Function
sub main()
viewComic("ext1:/Comics/Wonder Woman/Wonder Woman 002")
end sub
function viewComic(path as string)
'Check if the screen is in HD or not.
if IsHD()
screen=CreateObject("roScreen", true, 1280, 720) 'try this to see zoom
else
screen=CreateObject("roScreen", true)
endif
imagefiles = matchfiles(path,"*.jpg")
ImageIndex = 0
print imagefiles.count()
backgroundRegion = [imagefiles.count()]
msgport = CreateObject("roMessagePort")
screen.SetPort(msgport)
for i = 0 to imagefiles.count() - 1
print imagefiles[i]
bmImage = invalid
bmImage = CreateObject("roBitmap", path + "/" + imagefiles[i])
if bmImage = invalid then
print "bmImage is invalid"
end if
backgroundRegion[i]=CreateObject("roRegion", bmImage, 0, 0, screen.getwidth(), screen.getheight())
if backgroundRegion[i] = invalid then
print "create region failed"
end if
end for
NewFile:
'Set background region to that of the image loaded in bigbm.
'backgroundRegion=CreateObject("roRegion", bigbm, 0, 0, screen.getwidth(), screen.getheight())
'Check if background region was unable to be loaded.
'Prevent image from overscrolling. Stops at image edges.
backgroundRegion[ImageIndex].SetWrap(false)
'Output image to screen.
screen.drawobject(0, 0, backgroundRegion[ImageIndex])
screen.SwapBuffers()
screen.finish()
movedelta = 16
if (screen.getwidth() <= 720)
movedelta = 8
endif
codes = bslUniversalControlEventCodes()
pressedState = -1 ' If > 0, is the button currently in pressed state
while true
if pressedState = -1 then
msg=wait(0, msgport) ' wait for a button press
else
msg=wait(1, msgport) ' wait for a button release or move in current pressedState direction
endif
if type(msg)="roUniversalControlEvent" then
keypressed = msg.GetInt()
print "keypressed=";keypressed
if keypressed=codes.BUTTON_UP_PRESSED then
Zip(screen, backgroundRegion, 0,-movedelta) 'up button pressed
pressedState = codes.BUTTON_UP_PRESSED
else if keypressed=codes.BUTTON_DOWN_PRESSED then
Zip(screen, backgroundRegion, 0,+movedelta) ' down button pressed
pressedState = codes.BUTTON_DOWN_PRESSED
else if keypressed=codes.BUTTON_RIGHT_PRESSED then
Zip(screen, backgroundRegion, +movedelta,0) ' right button pressed
pressedState = codes.BUTTON_RIGHT_PRESSED
else if keypressed=codes.BUTTON_LEFT_PRESSED then
Zip(screen, backgroundRegion, -movedelta, 0) ' left button pressed
pressedState = codes.BUTTON_LEFT_PRESSED
else if keypressed = 8 then
print "Rewind"
if ImageIndex = 0 then
'Ignore forward page request if at end of imagelist.
else
ImageIndex = ImageIndex - 1
GOTO NewFile
end if
else if keypressed = 9 then
print "Fast Forward"
if ImageIndex = ImageFiles.count() then
'Ignore forward page request if at end of imagelist.
else
ImageIndex = ImageIndex + 1
GOTO NewFile
end if
else if keypressed=codes.BUTTON_BACK_PRESSED then
pressedState = -1
exit while
else if keypressed=codes.BUTTON_UP_RELEASED or keypressed=codes.BUTTON_DOWN_RELEASED or keypressed=codes.BUTTON_RIGHT_RELEASED or keypressed=codes.BUTTON_LEFT_RELEASED then
pressedState = -1
end if
else if msg = invalid then
print "eventLoop timeout pressedState = "; pressedState
print "ERROR: msg is Invalid"
if pressedState=codes.BUTTON_UP_PRESSED then
Zip(screen, backgroundRegion, 0,-movedelta) 'up button released
else if pressedState=codes.BUTTON_DOWN_PRESSED then
Zip(screen, backgroundRegion, 0,+movedelta) ' down button released
else if pressedState=codes.BUTTON_RIGHT_PRESSED then
Zip(screen, backgroundRegion, +movedelta,0) ' right button released
else if pressedState=codes.BUTTON_LEFT_PRESSED then
Zip(screen, backgroundRegion, -movedelta, 0) ' left button released
end if
end if
end while
end function
function Zip(screen, region, xd, yd)
region.Offset(xd,yd,0,0)
screen.drawobject(0, 0, region)
screen.SwapBuffers()
end function