You need to mask the mask. First draw the gradient in a picture that will act as the mask. Then create a second picture that draws white at just the rounded corners and draw that onto the gradient. Now this gradient image represents the masking you want. Create a third picture and set it’s mask to the gradient and return that.
[code]Function makeMask(g as Graphics, corner As integer) As Picture
//make an image of the gradient
dim gradmask As Picture = new Picture(g.Width, g.Height, 32)
dim gg As Graphics = gradmask.Graphics
gg.ForeColor = &cFFFFFF //fill white so it’s ‘clear’
gg.FillRect(0, 0, g.Width, g.Height)
dim max as integer = g.Height/2 //fill with gradient
dim ratio as double
for i as Integer=0 to max
ratio = i / max * 255
gg.ForeColor=rgb(ratio, ratio, ratio)
gg.DrawLine 0,i,g.Width,i
next
//make an image that will draw white at just the corners
dim rectmask As Picture = new Picture(g.Width, g.Height, 32)
gg = rectmask.Mask.Graphics
gg.ForeColor = &c000000
gg.FillRect(0, 0, g.Width, g.Height)
gg.ForeColor = &cFFFFFF
gg.FillRoundRect(0, 0, g.Width, g.Height, corner, corner)
//draw the white corners onto the gradient (so the corners are clear)
gradmask.Graphics.DrawPicture(rectmask, 0, 0)
//make an image with the constructed gradient
dim p As new Picture(g.Width, g.Height, 32)
p.Mask.Graphics.DrawPicture(gradmask, 0, 0)
return p
End Function
[/code]
Also, I modified it to take the corner radius so call it like this…
dim p as Picture = self.makeMask2(g, 13)