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: 
newchannel
Roku Guru

Centering the Bitmap for both for HD and SD?

I have a bitmap that is centered in HD mode but in SD mode the image is off to the bottom right corner. And, if I center the bitmap image for the SD mode, then it makes the HD bitmap image go to the upper right.

What parameter determines how to use a bitmap image from the package and have it centered for both HD and SD? The 0,0 for the x,y with canvas.drawobject right? But making the image centered for each HD and SD isn't working for me and not sure what to change.

  bmp=createobject("roBitmap","pkg:/images/xxxxx1280x720.png")
bmp.setAlphaEnable(true)

canvas.drawobject(0,0,bmp)
canvas.swapbuffers()
http://www.victoryNOWfilmsandtv.com
0 Kudos
5 REPLIES 5
EnTerr
Roku Guru

Re: Centering the Bitmap for both for HD and SD?

You are calling swapBuffers() and drawObject(), so i figure "canvas" is roScreen and not roImageCanvas?
If you create roScreen without specifying dimensions, it will use native resolution - which differ for HD and SD modes (spoiler alert. HD has more pixels). So you either have to place images at different coordinates manually - or force the same resolution, read http://sdkdocs.roku.com/display/sdkdoc/roScreen for more.
0 Kudos
newchannel
Roku Guru

Re: Centering the Bitmap for both for HD and SD?

For this line of code:

canvas=CreateObject("roScreen",TRUE) 'user interface

I made an attempt to make it as canvas=CreateObject("roScreen",TRUE, 1280, 720) 'user interface just to see what the result would be. The bitmap image loaded centered but then the video was playing in only the top left corner.

I know with the channel images there is HD setting and an SD setting so I need to figure out how to set it so that the proper image will load for each dimension.

I see the following area in the code. Is this the area I should be focusing on in order to set a bit map for the HD and a different one for the SD?

     bmp=createobject("roBitmap","pkg:/images/xxxxx.png")
bmp.setAlphaEnable(true)

canvas.drawobject(0,0,bmp)
canvas.swapbuffers()
http://www.victoryNOWfilmsandtv.com
0 Kudos
destruk
Streaming Star

Re: Centering the Bitmap for both for HD and SD?

You can probably check the rodeviceinfo for the current screen resolution or type setting.
Any of these would suffice --


Function GetDisplayType()
Return CreateObject("roDeviceInfo").GetDisplayType()
'4x3 standard
'16x9 anamorphic
'HDTV
End Function

Function GetDisplayMode()
Return CreateObject("roDeviceInfo").GetDisplayMode()
'480i
'720p
End Function

Function GetDisplayAspectRatio()
Return CreateObject("roDeviceInfo").GetDisplayAspectRatio()
'4x3
'16x9
End Function

Function GetDisplaySize()
Return CreateObject("roDeviceInfo").GetDisplaySize()
'Associative Array with values W for width and h for height
'{w:1080 h:720}
End Function


You would put your hook to load the graphic you want based on the result of any of these functions.
0 Kudos
newchannel
Roku Guru

Re: Centering the Bitmap for both for HD and SD?

I have the following:

   'Resolution-specific settings:
mode=CreateObject("roDeviceInfo").GetDisplayType()
If mode="HDTV"
layout={
full: {x:0,y:0,w:canvas.GetWidth(),h:canvas.GetHeight()}
top: { x: 0, y: 0, w:1280, h: 130 }
left: { x: 249, y: 177, w: 391, h: 291 }
right: { x: 700, y: 177, w: 350, h: 291 }
bottom: { x: 249, y: 500, w: 780, h: 300 }
}
'background="pkg:/images/back-hd.jpg"
headerfont=fonts.Get("lmroman10 caps",50,50,FALSE)
Else
layout={
full: {x:0,y:0,w:canvas.GetWidth(),h:canvas.GetHeight()}
top: { x: 0, y: 0, w: 720, h: 80 }
left: { x: 100, y: 100, w: 280, h: 210 }
right: { x: 400, y: 100, w: 220, h: 210 }
bottom: { x: 100, y: 340, w: 520, h: 140 }
}
'background="pkg:/images/back-sd.jpg"
headerfont=fonts.Get("lmroman10 caps",30,50,FALSE)
End If



And have the following with the bitmap image that I want to use that is in my images folder.

   bmp=createobject("roBitmap","pkg:/images/.png")
bmp.setAlphaEnable(true)

canvas.drawobject(0,0,bmp)
canvas.swapbuffers()
startupcomplete=false



In the first set of code above, what does the back-sd.jpg refer too? It's not an image that I have. Is it just the background that the bitmap is being drawn over?
http://www.victoryNOWfilmsandtv.com
0 Kudos
newchannel
Roku Guru

Re: Centering the Bitmap for both for HD and SD?

In case it is helpful to other code newbies, I used this per Joel and it fixed it:

[code]If mode="HDTV" then

bmp=createobject("roBitmap","pkg:/images/xxxxx_HD.png")

else

bmp=createobject("roBitmap","pkg:/images/xxxxxx_SD.png")

end if[/code]
http://www.victoryNOWfilmsandtv.com
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.