theSmaw
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2013
12:35 AM
Controlling bitmap opacity
I believe this may already have been asked and not been answered: viewtopic.php?f=34&t=50839&p=344901&hilit=alpha#p344901
I have a requirement to fade images (roBitmap) in and out on the screen. Is this possible?
Thanks
I have a requirement to fade images (roBitmap) in and out on the screen. Is this possible?
Thanks
10 REPLIES 10
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2013
12:44 AM
Re: Controlling bitmap opacity
http://sdkdocs.roku.com/plugins/viewsou ... Id=3114035
Looks like by redrawing the destination surface you should be able to change the alpha values for combining new data drawn to it.
Looks like by redrawing the destination surface you should be able to change the alpha values for combining new data drawn to it.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2013
06:46 AM
Re: Controlling bitmap opacity
If you're just wanting to fade in and out and not do a cross fade, and the background color is solid, you could fake it by drawing a rect over the bitmap with increasing/decreasing alpha values.
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2013
12:07 PM
Re: Controlling bitmap opacity
This hasn't been added to the online docs yet:
DrawObject, DrawScaledObject, & DrawRotatedObject take an optional RGBA color parameter. To modulate the alpha, pass in &hFFFFFFAA where AA is the hexadecimal alpha value.
Example: DrawScaledObject(x as Integer, y as Integer, scaleX as Float, scaleY as Float, src as Object, rgba as integer)
(this allows you do do a crossfade of solid images).
This does not work on 3.1 firmware devices and will cause your code to crash.
- Joel
DrawObject, DrawScaledObject, & DrawRotatedObject take an optional RGBA color parameter. To modulate the alpha, pass in &hFFFFFFAA where AA is the hexadecimal alpha value.
Example: DrawScaledObject(x as Integer, y as Integer, scaleX as Float, scaleY as Float, src as Object, rgba as integer)
(this allows you do do a crossfade of solid images).
This does not work on 3.1 firmware devices and will cause your code to crash.
- Joel
theSmaw
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2013
01:37 AM
Re: Controlling bitmap opacity
Brilliant Joel, that's exactly what I'm looking for. Thanks!
Arthy74
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2015
07:25 AM
Re: Controlling bitmap opacity
Hello,
I am sorry but apparently i have an error when using this last "mask" parameter with DrawScaledObject
(works for DrawObject method)
Show this error:
Type Mismatch. (runtime error &h18)
Tested on Roku 3 and Roku 2 XS (both updated)
I am sorry but apparently i have an error when using this last "mask" parameter with DrawScaledObject
(works for DrawObject method)
m.canvas.DrawScaledObject(xOffset, yOffset, m.scaleX, m.scaleY, m.bitmapData, &hFFFFFFFF)
Show this error:
Type Mismatch. (runtime error &h18)
Tested on Roku 3 and Roku 2 XS (both updated)

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2015
01:22 PM
Re: Controlling bitmap opacity
Could you be using a legacy Roku device running 3.1 firmware? Those don't support the extra parameter.
- Joel
- Joel

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2015
03:26 PM
Re: Controlling bitmap opacity
"RokuJoel" wrote:
Could you be using a legacy Roku device running 3.1 firmware? Those don't support the extra parameter.
- Joel
Pretty sure there are no Roku3's running 3.1
I use this feature to death but because of it's un-documented-ness I only know about it because Joel has posted it before. I've never made it work on drawRotatedobject and i know i've tried. Works like a charm on drawObject & drawscaledobject though.
Kinetics Screensavers

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2015
05:34 PM
Re: Controlling bitmap opacity
"Arthy74" wrote:
Show this error:
Type Mismatch. (runtime error &h18)
The "Type Mismatch" would suggest that one of your variables isn't equal to what you think it is. Is it possible you don't have a valid bitmap in m.bitmapData? Can you verify, without changing anything else in the code, that it works if you remove the last parameter?
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
mbhakak
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2015
08:18 AM
Re: Controlling bitmap opacity
I tested the code you have with my own bitmap, and indeed, I get the type mismatch error when I apply a rgba value on the DrawScaledObject call.
I verified that the image is fine, so when I remove the rgba parameter, the image does show up.
I am running Roku 3 on a 6.1 build
I did some more digging and found that the method DrawObject also has a RGBA parameter that is undocumented.
That method worked.
SO: someScreen.DrawObject(20, 20, image, &hFFFFFF33) did show the image with an alpha, no error. Hope that helps....
However, I can imagine someone wanting to draw a scaled image scaled with transparency....hmmm, something to worry about later?
I verified that the image is fine, so when I remove the rgba parameter, the image does show up.
I am running Roku 3 on a 6.1 build
I did some more digging and found that the method DrawObject also has a RGBA parameter that is undocumented.
That method worked.
SO: someScreen.DrawObject(20, 20, image, &hFFFFFF33) did show the image with an alpha, no error. Hope that helps....
However, I can imagine someone wanting to draw a scaled image scaled with transparency....hmmm, something to worry about later?