|
CogImage8Grey maskImg/* = new CogImage8Grey((int)dieWidth, (int)dieHeight)*/;
// 创建与灰度图像相同大小的透明图像
Bitmap maskBitmap = new Bitmap((int)dieWidth, (int)dieHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// 设置遮罩图像中的所有像素为半透明绿色
System.Drawing.Color transparentGreen = System.Drawing.Color.FromArgb(50, 173, 216, 230);
using (Graphics g = Graphics.FromImage(maskBitmap))
{
g.Clear(System.Drawing.Color.Transparent);
using (SolidBrush brush = new SolidBrush(transparentGreen))
{
g.FillRectangle(brush, 0, 0, maskBitmap.Width, maskBitmap.Height);
}
}
// 将遮罩图像应用于灰度图像
maskImg = new CogImage8Grey(maskBitmap); |
|