OK, I have isolated the problem. I was wrong. It is not related to the fact that the image is drawn in a bitmap and the bitmap applied to the panel. It seems related to the fact that the image is resized before applying the mask.
I have written a little demo script. (It crashes if you minimize foobar or hide the panel somehow, but that's not the problem. I just wanted to keep the code as simple and short as possible.)
This code works as expected:
var g_img = gdi.Image(fb.ProfilePath + "\\wsh_scripts\\samples\\images\\image.jpg");
var g_mask = gdi.Image(fb.ProfilePath + "\\wsh_scripts\\samples\\images\\mask.png");
function on_paint(gr) {
var ww = window.Width;
var wh = window.Height;
var Rimg = g_img; // this line is OK
var Rmask = g_mask.Resize(Rimg.Width, Rimg.Height);
Rimg.ApplyMask(Rmask);
gr.DrawImage(Rimg, 0, 0, ww, wh, 0, 0, Rimg.Width, Rimg.Height);
Rimg.Dispose();
Rmask.Dispose();
}
Note that the original image is simply copied to the local variable Rimg, then the mask is resized and applied.
This code doesn't work:
var g_img = gdi.Image(fb.ProfilePath + "\\wsh_scripts\\samples\\images\\image.jpg");
var g_mask = gdi.Image(fb.ProfilePath + "\\wsh_scripts\\samples\\images\\mask.png");
function on_paint(gr) {
var ww = window.Width;
var wh = window.Height;
var Rimg = g_img.Resize(ww, wh); // this line causes the bug!
var Rmask = g_mask.Resize(Rimg.Width, Rimg.Height);
Rimg.ApplyMask(Rmask);
gr.DrawImage(Rimg, 0, 0, ww, wh, 0, 0, Rimg.Width, Rimg.Height);
Rimg.Dispose();
Rmask.Dispose();
}
The only difference is that the image is resized when it is placed in the Rimg variable.
If you remove the Rimg.ApplyMask(Rmask); line, the image is correctly drawn, without transparency.
The conclusion is that there is a bug in the ApplyMask() or Resize() method, that makes them incompatible.
That bug was not present in WSHPM v1.4.
T.P. Wang, can you have a look?