GDI+ 如何实现像AlphaBlend函数样半透明效果? GDI+ 如何实现像AlphaBlend函数样半透明效果? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GDI+实现透明很简单,设置下啊落发值即可 看看MSDN上的:Using a Color Matrix to Set Alpha Values in Images PNG 格式直接往上画就可以! 下面是一个淡入淡出的效果,你参考一下吧:Graphics g=this.CreateGraphics(); g.Clear(Color.Black); Bitmap bitmap=new Bitmap("demo.bmp"); int iWidth = bitmap.Width; int iHeight = bitmap.Height; //初始化色彩变换矩阵 float[][] tem= { new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f}, new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f} }; ColorMatrix colorMatrix=new ColorMatrix(tem); ImageAttributes imageAtt=new ImageAttributes(); //从0到1进行修改色彩变换矩阵主对角线上的数值 //使三种基准色的饱和度渐增 for(float i=0.0f;i<=1.0f;i+=0.02f) { colorMatrix.Matrix00=i; colorMatrix.Matrix11=i; colorMatrix.Matrix22=i; colorMatrix.Matrix33=i; //设置色彩校正矩阵 imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default,ColorAdjustType.Bitmap); //绘制图片 g.DrawImage( bitmap, new Rectangle(0, 0, iWidth, iHeight), 0,0, iWidth,iHeight, GraphicsUnit.Pixel, imageAtt); } MessageBox.Show("下面演示淡出效果"); //从1到0进行修改色彩变换矩阵主对角线上的数值 //依次减少每种色彩分量 for(float i=1.0f;i>=0.0f;i-=0.02f) { colorMatrix.Matrix00=i; colorMatrix.Matrix11=i; colorMatrix.Matrix22=i; colorMatrix.Matrix33=i; //设置色彩校正矩阵 imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default,ColorAdjustType.Bitmap); //绘制图片 g.DrawImage( bitmap, new Rectangle(0, 0, iWidth, iHeight), 0,0, iWidth,iHeight, GraphicsUnit.Pixel, imageAtt); } 钩子消息处理函数里下面判断是进入消息处理函数的吗??? 如何编写FTP服务器 在搞DLL中遇到的问题,在线等~~~谢谢! ftp连接问题 如何在程序使用ShellExecute启动自己的exe程序 右键动态popUP菜单是如何实现的 高分征集开发"远程控制软件"方案! 库调用出错,求救? VB用ADO可以压缩ACCESS数据库,VC怎么做? 高分求购FlexGrid 和 edit[或其它如:combobox...] 结合进行输入的源代码或方案。 c# listbox 问题 关于USING NAMESPACE,挺有趣,近来看看
Using a Color Matrix to Set Alpha Values in Images
g.Clear(Color.Black);
Bitmap bitmap=new Bitmap("demo.bmp");
int iWidth = bitmap.Width;
int iHeight = bitmap.Height; //初始化色彩变换矩阵
float[][] tem=
{
new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[]{0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
new float[]{0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
};
ColorMatrix colorMatrix=new ColorMatrix(tem);
ImageAttributes imageAtt=new ImageAttributes(); //从0到1进行修改色彩变换矩阵主对角线上的数值
//使三种基准色的饱和度渐增
for(float i=0.0f;i<=1.0f;i+=0.02f)
{
colorMatrix.Matrix00=i;
colorMatrix.Matrix11=i;
colorMatrix.Matrix22=i;
colorMatrix.Matrix33=i;
//设置色彩校正矩阵
imageAtt.SetColorMatrix(colorMatrix,
ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
//绘制图片
g.DrawImage(
bitmap, new Rectangle(0, 0, iWidth, iHeight),
0,0,
iWidth,iHeight,
GraphicsUnit.Pixel,
imageAtt);
} MessageBox.Show("下面演示淡出效果");
//从1到0进行修改色彩变换矩阵主对角线上的数值
//依次减少每种色彩分量
for(float i=1.0f;i>=0.0f;i-=0.02f)
{
colorMatrix.Matrix00=i;
colorMatrix.Matrix11=i;
colorMatrix.Matrix22=i;
colorMatrix.Matrix33=i;
//设置色彩校正矩阵
imageAtt.SetColorMatrix(colorMatrix,
ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
//绘制图片
g.DrawImage(
bitmap, new Rectangle(0, 0, iWidth, iHeight),
0,0,
iWidth,iHeight,
GraphicsUnit.Pixel,
imageAtt);
}