Home Technical Talk

Maxscript - How to get alpha from bitmap?

polycount lvl 666
Offline / Send Message
PolyHertz polycount lvl 666
I'm trying to create a simple rollout with a bitmap image for a button, but the image needs to use its alpha channel as the mask. The problem is while it's easy to get the bitmap I can't figure out how to use the alpha in it.

This is what I'm doing:

rollout image_button_test "Image Button" width:150 height:100 (<br>    local iconDir = (getDir #UI_ln) + "Icons"<br>    local theBitmap = openBitMap (iconDir + "\EditMesh_24i.bmp")<br>    local theAlpha = ???<br>    button theButton "btn" pos:[25,29] width:24 height:24 images:#(theBitmap, theAlpha, 10, 2, 7, 1, 1)<br>)<br>createdialog image_button_test

I thought I could just do something like "theBitmap.a" or "theBitmap.alpha" but no such luck.
Anyone know how to go about getting the alpha from the image so it can be used as a mask?

Replies

  • Swordslayer
    Options
    Offline / Send Message
    Swordslayer interpolator
    Just to doublecheck since you included the Edge icon in the example code, you want to use a different, custom file with alpha, right? Otherwise, you could just use button theButton "btn" pos:[25,29] width:24 height:24 iconName:"Common\Edge"

  • Swordslayer
    Options
    Offline / Send Message
    Swordslayer interpolator
    To get an alpha bitmap, you can use pasteBitmap:

    delete objects<br>Teapot wirecolor:white segs:10<br>camObj = TargetCamera pos:[-10,-130,30] target:(TargetObject pos:[-1,0,10])<br><br>imgWithAlpha = bitmap 320 240<br>render camera:camObj to:imgWithAlpha vfb:off<br><br>(<br>	fn compAlpha c1 p1 c2 p2 =<br>		color c1.a c1.a c1.a<br><br>	local imgAlpha = bitmap imgWithAlpha.width imgWithAlpha.height<br>	pasteBitmap imgWithAlpha imgAlpha [0,0] [0,0] type:#function function:compAlpha<br>	display imgAlpha <br>)


Sign In or Register to comment.