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: 
TheEndless
Channel Surfer

[SDK Bug] DrawScaledObject and SetScaleMode(1)

I spent hours trying to figure out why this wouldn't work for me tonight, and finally found the problem...

DrawScaledObject() only works when the target is an roBitmap if SetScaleMode() is set to 0. If the scale mode is set to 1, it won't error, but it also won't draw anything. If the target is an roRegion, it will work with a scale mode of either 0 or 1, so the workaround is to create an roRegion for the bitmap and draw to that instead of the bitmap directly.

To further confound things, the documentation fails to mention that roRegion implements the ifDraw2D interface.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
3 REPLIES 3
RokuKevin
Visitor

Re: [SDK Bug] DrawScaledObject and SetScaleMode(1)

Thanks for pointing this out! We'll update the docs.

--Kevin
0 Kudos
MazeWizzard
Visitor

Re: [SDK Bug] DrawScaledObject and SetScaleMode(1)

IDK if I could be doing something wrong, but DrawScaledObject() isn't behaving as expected, even when it does draw.
For example, I'm scaling a bitmap up by 2x in each direction. This is done so that I only need 1/4 of the space to store the bitmap. The bitmap is wider than the screen/viewport. I use an roRegion object to scroll through it. regionStart% represents the x-offset into that source bitmap. The ViewBM is the destination bitmap that receives the scaled object.


<snip>
backgroundRegion = CreateObject("roRegion", BackgroundBM, regionStart%, 0, bw%, bh%)
ViewBM.DrawScaledObject(0, 0, 2.0, 2.0, backgroundRegion)
ViewBM.DrawObject(0,0, backgroundRegion) ' <--- DEBUGGING test window - unscaled in u/l corner
BackgroundSprite.SetRegion(viewRegion)
<snip>


There is an extra line of testing code as noted by the arrow. It shows an unscaled version of the source in the upper left of the viewport.

The issue: the unscaled bitmap works fine and scrolls as expected as regionStart% is incremented. bw% and bh% are set to the correct sub-section of the source bitmap. The scaled result is moving diagonally even though the source region's Y value is 0. The scaled map at source-region 0,0 looks fine (hard to tell with overscan).

Thus, there seems to be an issue with a source region not at 0,0. This could be remedied by blitting it to a temp bitmap 1st, then scaling that, but I thought I should mention it since it is supposed to work on an roRegion. Or did I miss something/mess up my code and/or not understand the function?

Anyone else have an issue with a scaling bitmap using roRegion/DrawScaledObject at non 0,0 source?

P.S. Software version 3.0 - build 2227
0 Kudos
EnTerr
Roku Guru

Re: [SDK Bug] DrawScaledObject and SetScaleMode(1)

"RokuKevin » Fri Jul 15, 2011" wrote:
Thanks for pointing this out! We'll update the docs.
--Kevin

I don't see anything on this in the doc since then... forgot to update?

roRegion still does not show ifDraw2D - which is big omission and people keep re-discovering it.
Also I have no idea if SetScaleMode() is fixed now or still acts as observed before?
0 Kudos