picturebox淡入淡出图像

pavel881001 2010-02-04 01:09:07
有没有什么方法使picturebox控件在加载图像时使用淡入淡出的方式
...全文
264 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
薄冰2010 2010-02-04
  • 打赏
  • 举报
回复
将picturebox的大小适合一个窗体,而后同过时间控件来控制窗体的透明度opcity
flyerwing 2010-02-04
  • 打赏
  • 举报
回复
zsz1001

(奋斗不止)
--------------------------------
奋斗机CSDN中的战斗机
flyerwing 2010-02-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 blueteeth_yl 的回复:]
C# codeprivatevoid FadeDraw(Graphics g)
{float[][] matrix=newfloat[][]{newfloat[]{_opaque,0,0,0,0},newfloat[]{0,_opaque,0,0,0},newfloat[]{0,0,_opaque,0,0},newfloat[]{0,0,0,_opaque,0},newfloat[?-
[/Quote]
蓝牙的估计行吧
zsz1001 2010-02-04
  • 打赏
  • 举报
回复
一楼的方法好
  • 打赏
  • 举报
回复
一楼的方法好,简单可行
二楼的方法太复杂
pavel881001 2010-02-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 blueteeth_yl 的回复:]
C# codeprivatevoid FadeDraw(Graphics g)
{float[][] matrix=newfloat[][]{newfloat[]{_opaque,0,0,0,0},newfloat[]{0,_opaque,0,0,0},newfloat[]{0,0,_opaque,0,0},newfloat[]{0,0,0,_opaque,0},newfloat[]{0,0,0,0,1.0f}};
ImageAttributes attributes=new ImageAttributes();
ColorMatrix colorMatrix=new ColorMatrix(matrix);int width= _image.Width;int height= _image.Height;

attributes.SetColorMatrix(
colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(
_image,new Rectangle(0,0, Width, Height),0,0,
width,
height,
GraphicsUnit.Pixel,
attributes);

attributes.Dispose();

}
设置_opaque的值

然后在timer控件来改变_opaque的值;
[/Quote]

你这个过程是一层一层刷下来的,好像不是我想要的那个效果,不太自然,而且为什么显示的图像是不完整的呢,最底下一块看不见
blueteeth_yl 2010-02-04
  • 打赏
  • 举报
回复

private void FadeDraw(Graphics g)
{

float[][] matrix = new float[][]{
new float[]{_opaque,0,0,0,0},
new float[]{0,_opaque,0,0,0},
new float[]{0,0,_opaque,0,0},
new float[]{0,0,0,_opaque,0},
new float[]{0,0,0,0,1.0f}};
ImageAttributes attributes = new ImageAttributes();
ColorMatrix colorMatrix = new ColorMatrix(matrix);

int width = _image.Width;
int height = _image.Height;

attributes.SetColorMatrix(
colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(
_image,
new Rectangle(0, 0, Width, Height),
0,
0,
width,
height,
GraphicsUnit.Pixel,
attributes);

attributes.Dispose();

}
设置_opaque的值

然后在timer控件来改变_opaque的值;



Baesky 2010-02-04
  • 打赏
  • 举报
回复
在picturebox的上面覆盖一个自定义的控件,这个控件做成背景透明,然后动态调整透明度。模拟慢慢显示或者慢慢消失的效果。

110,500

社区成员

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

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

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