Hello,
I want to use pictures with masks (as I always did). So, every picture I create uses the 3 parameters constructor (depth=32).
The pictures are used for custom buttons. The background of these buttons will always be transparent and the button (picture) may be enabled or disabled.
Until recently, I always did this correctly with masks (the mask is white where the original picture is white and black (enabled state) or grey (disabled state) for all other pixels).
With the addition of alpha channels in the recent builds, I get everything but working code, including weird behaviours…
So, I draw my two pictures separately; then, the “Enabled” computed property should set the corresponding mask:
Sub Set
mEnabled=value
dim p As Picture
p=if(value,MaskEnabled,MaskDisabled)
Icon.ApplyMask p
IconPressed.ApplyMask p
End Sub
I’m in early stage with this app, still building the basis. My “dummy” MouseDown event (in the parent canvas that draws all the buttons) does this:
- Find the clicked button
- Toggle its Enabled property (thus triggering the method above)
- Invalidate the canvas to see the change
Seeing nothing changing, I’d like to debug the app. Inspecting in the IDE after the ApplyMask calls, the Icon’s mask is blank (just a cross like when none is set) and the “main” picture looks weird (seems like it’s only showing the inverted assigned mask, a picture I never see in the running app).
If I draw the picture and its mask at the bottom of the canvas, in the running app, like this:
if Buttons.Ubound>=4 then
btn=Buttons(4)
dim p1,p2 As Picture
p1=btn.Icon
if p1<>nil then p2=btn.Icon.CopyMask
g.DrawPicture p1,0,g.Height-25
g.DrawPicture p2,p1.Width,g.Height-25
end if
… then, here, they both appear as I expect, but they are separate. The original button, with the applied mask, always shows the button as Enabled.
When I inspect the Icon (picture), I’m seeing it has a depth of 32 but HasAlphaChannel is also true, which is unexpected and confusing (for me at least). The documentation says this for the ApplyMask method:
“When used on a Picture with an alpha channel, this overwrites the Picture’s alpha channel with the mask data. When used on a Picture with a mask, it overwrites the current mask with a copy of the mask passed in.”
So, mines both have an alpha channel and a mask. Which sentence above applies?
I’m thinking the trouble I have is I want a picture with only a mask (no alpha channel) but even with constructing with the 3 parameters, the HasAlphaChannel property is true. Since debugging with the IDE seems broken in this area, I’m clueless as to how to make it properly.
Any idea?