向zgke请教关于alpha的问题。

tank_2009 2009-09-08 09:25:51


Bitmap _NewBitmap = new Bitmap(dataGridView1.Width, dataGridView1.Height);

#region
// 为NewBitmap 赋值
#endregion

pictureBox1.Image = myAlpha(_NewBitmap);
pictureBox1.Image.Save(@"c:\1.png");


private Bitmap myAlpha(Bitmap _Bitmap)
{
Graphics _Graphcis = Graphics.FromImage(_Bitmap);

Point _Left1 = new Point(0, 0);
Point _Left2 = new Point(_Bitmap.Width, 0);
Point _Left3 = new Point(_Bitmap.Width, _Bitmap.Height / 2);
Point _Left4 = new Point(0, _Bitmap.Height / 2);

Point[] _Point = new Point[] { _Left1, _Left2, _Left3, _Left4 };
PathGradientBrush _SetBruhs = new PathGradientBrush(_Point, WrapMode.TileFlipY);
_SetBruhs.CenterPoint = new PointF(0, 0);
_SetBruhs.FocusScales = new PointF(_Bitmap.Width / 2, 0);
_SetBruhs.CenterColor = Color.FromArgb(255, 255, 255, 255);
_SetBruhs.SurroundColors = new Color[] { Color.FromArgb(0, 255, 255, 255) };

_Graphcis.FillRectangle(_SetBruhs, new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height));

return _Bitmap;
}



我把加入alpha的图像放入到pictureBox中,也没有出现透明。没分了,实在抱歉
...全文
203 17 打赏 收藏 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgke 2009-09-08
  • 打赏
  • 举报
回复
恩 这个问题..鼠标事件里 你的先判断需要截图不需要..不需要截图就不执行图形操作..看看
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
好吧...非常感谢 ....

另外 我现在让pictureBox随便着鼠标在DataGridView上面移动。感觉pictureBox显示速度非常慢。
鼠标移动速度稍快,pictureBox就显示不出,请问可以有别的方法来代替,一个图像跟随着鼠标移动,并且效率更高吗?

imageList因为size有限,所以没有考虑。
zgke 2009-09-08
  • 打赏
  • 举报
回复
简单的办法你可以考虑使用 多传递一个参数来实现..
tank_2009 2009-09-08
  • 打赏
  • 举报
回复

float[][] nArray ={ new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 120, 0}, // 120为透明度
new float[] {0, 0, 0, 0, 1}};
ColorMatrix matrix = new ColorMatrix(nArray);
ImageAttributes attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
Bitmap resultImage = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);

Graphics g = Graphics.FromImage(resultImage);
g.DrawImage(pictureBox1.Image, new Rectangle(0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height), 0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height, GraphicsUnit.Pixel, attributes);
pictureBox1.Image = resultImage;




我另外找了一个代码,实现将picturebox中图像变为半透明状,但是能再帮我改一下,和你的那个方法结合,形成渐变为透明的效果。能实现吗?
zgke 2009-09-08
  • 打赏
  • 举报
回复
自己写个更改ALPAH的方法 不知道可以不
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
up............
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
我把这句代码加在 FillRectangle 的后面了

但是还是白色的。
zgke 2009-09-08
  • 打赏
  • 举报
回复
_Graphcis.CompositingMode = CompositingMode.SourceOver;

这样.
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
第2个方法 附值的时候就设置透明

应该怎样做呢?
zgke 2009-09-08
  • 打赏
  • 举报
回复
第1个方法 myAlpha传递背景色.
第2个方法 附值的时候就设置透明
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
赋值确实不是透明的。
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
没有透明吧...PictureBox的背景是透明的。但是赋值后,图像上下应该是橙色。
zgke 2009-09-08
  • 打赏
  • 举报
回复
赋值的时候就已经不是透明的了把
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
tank_2009 2009-09-08
  • 打赏
  • 举报
回复
结贴先...感谢zgke.
zgke 2009-09-08
  • 打赏
  • 举报
回复
这样 最笨的办法

public Bitmap SetAplha(Bitmap p_Bitmap)
{
Bitmap _SetBitmap = new Bitmap(p_Bitmap.Width, p_Bitmap.Height);
Graphics _GraphisSetBitmap = Graphics.FromImage(_SetBitmap);
_GraphisSetBitmap.DrawImage(p_Bitmap,new Rectangle(0, 0, p_Bitmap.Width, p_Bitmap.Height));
_GraphisSetBitmap.Dispose();

Bitmap _Bitmap = new Bitmap(_SetBitmap.Width, _SetBitmap.Height);
Graphics _Graphcis = Graphics.FromImage(_Bitmap);

Point _Left1 = new Point(0, 0);
Point _Left2 = new Point(_Bitmap.Width, 0);
Point _Left3 = new Point(_Bitmap.Width, _Bitmap.Height / 2);
Point _Left4 = new Point(0, _Bitmap.Height / 2);
Point[] _Point = new Point[] { _Left1, _Left2, _Left3, _Left4 };
PathGradientBrush _SetBruhs = new PathGradientBrush(_Point, WrapMode.TileFlipY);
_SetBruhs.CenterPoint = new PointF(0, 0);
_SetBruhs.FocusScales = new PointF(_Bitmap.Width / 2, 0);
_SetBruhs.CenterColor = Color.FromArgb(0, 251, 252, 253);
_SetBruhs.SurroundColors = new Color[] { Color.FromArgb(255, 251, 252, 253) };
_Graphcis.FillRectangle(_SetBruhs, new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height));
_Graphcis.Dispose();

BitmapData _NewData = _Bitmap.LockBits(new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height), ImageLockMode.ReadOnly, _Bitmap.PixelFormat);
byte[] _NewBytes = new byte[_NewData.Stride * _NewData.Height];
Marshal.Copy(_NewData.Scan0, _NewBytes, 0, _NewBytes.Length);
_Bitmap.UnlockBits(_NewData);

BitmapData _SetData = _SetBitmap.LockBits(new Rectangle(0, 0, _SetBitmap.Width, _SetBitmap.Height), ImageLockMode.ReadWrite, _SetBitmap.PixelFormat);
byte[] _SetBytes = new byte[_SetData.Stride * _SetData.Height];
Marshal.Copy(_SetData.Scan0, _SetBytes, 0, _SetBytes.Length);

int _WriteIndex = 0;

for (int i = 0; i != _SetData.Height; i++)
{
_WriteIndex = i * _SetData.Stride + 3;
for (int z = 0; z != _SetData.Width; z++)
{
_SetBytes[_WriteIndex] = _NewBytes[_WriteIndex];
_WriteIndex += 4;
}
}

Marshal.Copy(_SetBytes, 0, _SetData.Scan0, _SetBytes.Length);
_SetBitmap.UnlockBits(_SetData);

return _SetBitmap;

}

内容概要:WiFiSupply斯普莱WFS7000BI是一款高性能、电信工业级的室外型大功率无线基站,支持5.8GHz全频段(4920-6100MHz),基于MIMO 2T2R架构,最大发射功率达30dBm/1000mw,无线带宽最高300Mbps,点对点实际吞吐量超过150Mbps,支持TDMA时分多址技术,通信延迟≤1ms,具备强抗干扰能力和超远传输距离(桥接可达150公里以上)。设备集成16dBi双极化扇区天线,支持快速无缝漫游、多SSID、VLAN、QoS、VPN、防火墙、巨量安全隧道等多种网络功能,采用IP68防护等级和宽温设计(-45~85℃),具备防浪涌、防静电、电磁屏蔽等工业级防护特性,适用于复杂环境下的无线桥接与覆盖。支持胖瘦AP模式、本地及云端管理,并提供API接口实现第三方平台集成。; 适合人群:从事工业无线网络建设、系统集成、智能交通、智慧物流等领域的网络工程师、技术负责人及项目实施人员。; 使用场景及目标:适用于智慧交通、工业4.0、AMR/AGV小车组网、无人机遥控、车载船载视频传输、驾驶员考试系统、森林防火监控等对稳定性、低延迟、远距离通信要求高的室内外无线通信场景,目标是构建高可靠、高安全、长距离的无线网络传输系统。; 阅读建议:本文档技术参数详实,建议结合具体项目需求重点查阅频段、功率、组网模式、防护等级及管理方式等内容,便于选型与部署。
内容概要:WiFiSupply斯普莱WFS7000-52AX5是一款高性能、高负载型工业级双射频无线AP基站,支持2.4G和5.8G双频段WiFi6(802.11ax)标准,采用OFDMA、MIMO 4T4R架构及射频合路技术,实现最大1974Mbps的双频合并带宽。设备具备29dBm高发射功率、-96dBm高接收灵敏度,支持Fast Roaming快速漫游(切换延迟≤30ms)、多链路聚合、主备链路备份、巨量安全隧道等核心技术,保障低延迟、零丢包的稳定通信。配备5个千兆网口(含1个2.5G口)、支持POE/DC/端子多种供电方式,具备IP54防护、-45~85℃宽温运行、防浪涌防静电等工业级设计,适用于复杂恶劣环境。支持胖瘦一体模式、云端/本地/图形化多方式管理,并提供API接口便于第三方平台集成。; 适合人群:工业自动化、智能制造、智慧物流等领域中从事无线网络部署与运维的工程师和技术人员,具备基本网络知识和工业通信需求的专业用户。; 使用场景及目标:①用于AMR/AGV/RGV小车、无人叉车、穿梭车、天车、堆垛机等移动设备的无线联网;②满足无人机遥控、车载、船载、火车视频传输、分拣机PLC控制等高移动性、高可靠性场景的无线桥接与覆盖需求;③实现工业4.0环境下大规模终端接入、无缝漫游、安全传输的无线网络建设。; 阅读建议:本文档技术参数详尽,建议结合实际部署场景重点关注设备的射频性能、漫游切换、供电安装方式及管理功能,以便充分发挥其在高负载、强干扰工业环境下的优势。
内容概要:本文提出了一种基于混沌系统与DNA编码的彩色图像加密解密方案,旨在提升图像传输的安全性与抗干扰能力。通过结合混沌系统的初值敏感性、伪随机性和遍历性,以及DNA编码的高维信息存储与并行处理优势,实现对彩色图像RGB三通道的多层级加密。方案涵盖图像预处理、混沌序列生成、像素置乱、DNA编码扩散和通道融合等关键步骤,构建了复杂的双重混淆扩散机制。同时,系统开展了抗噪声与抗裁剪性能分析,验证了算法在高斯噪声、椒盐噪声干扰及不同面积、位置裁剪下的鲁棒性,结果表明解密图像仍能保持主体结构与核心信息的完整性。; 适合人群:具备一定信息安全与图像处理基础知识,从事信息隐藏、多媒体安全或密码学相关研究的研究生及科研人员。; 使用场景及目标:①应用于数字图像的安全传输与存储,如医疗影像、军事通信等高安全需求领域;②用于研究图像加密算法的抗攻击能力与鲁棒性机制;③为混沌系统与生物编码技术在信息安全中的融合应用提供理论支持与实践参考。; 阅读建议:建议结合Matlab代码实现对加密流程进行仿真复现,重点关注混沌参数设置、DNA编码规则选择对加密效果的影响,并通过添加不同类型与强度的噪声、裁剪攻击来测试算法鲁棒性,深入理解其安全机制与优化方向。

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧