几何尺寸与公差论坛

 找回密码
 注册
查看: 715|回复: 0

创建与灰度图像相同大小的透明图像

[复制链接]
发表于 2023-2-11 21:00:36 | 显示全部楼层 |阅读模式
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);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-5-5 06:51 , Processed in 0.033971 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表