C#中怎么设置鼠标移到图片上时出现特效~比如图片加亮或者方法或者其他~

nearthesun 2009-01-26 02:37:59
我是个菜鸟呀~呵呵~各位高手帮忙啊~
...全文
496 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hechenqingtian 2009-01-28
  • 打赏
  • 举报
回复
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">

img{

width:300px;
heigth:250px;
filter:alpha(opacity:50);
}


.over{
filter:alpha(opacity:100);
}


.out{
filter:alpha(opacity:50);
}
</style>


<script type="text/javascript">

function over(obj)
{
obj.className="over";
}


function out(obj)
{
obj.className="out";
}
</script>
</head>

<body>
<table border="0" width="800px">
<tr>
<td><img src="image/a.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
<td><img src="image/b.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
</tr>

<tr>
<td><img src="image/c.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
<td><img src="image/d.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
</tr>

</table>
</body>
</html>


hechenqingtian 2009-01-28
  • 打赏
  • 举报
回复
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">

img{

width:300px;
heigth:250px;
filter:alpha(opacity:50);
}


.over{
filter:alpha(opacity:100);
}


.out{
filter:alpha(opacity:50);
}
</style>


<script type="text/javascript">

function over(obj)
{
obj.className="over";
}


function out(obj)
{
obj.className="out";
}
</script>
</head>

<body>
<table border="0" width="800px">
<tr>
<td><img src="image/a.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
<td><img src="image/b.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
</tr>

<tr>
<td><img src="image/c.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
<td><img src="image/d.jpg" onmouseover="over(this)" onmouseout="out(this)" /></td>
</tr>

</table>
</body>
</html>


足球中国 2009-01-28
  • 打赏
  • 举报
回复
codeproject 上有个BUTTON的示例比较全比较好.
pp_shy 2009-01-28
  • 打赏
  • 举报
回复
在MouseEnter事件中实现光照效果

Graphics MyGraphics = this.pictureBox1.CreateGraphics();
MyGraphics.Clear(Color.White);
Bitmap MyBmp = new Bitmap(this.pictureBox1.Image, this.pictureBox1.Width, this.pictureBox1.Height);
int MyWidth = MyBmp.Width;
int MyHeight = MyBmp.Height;
Bitmap MyImage = MyBmp.Clone(new RectangleF(0, 0, MyWidth, MyHeight), System.Drawing.Imaging.PixelFormat.DontCare);
int A = Width / 2;
int B = Height / 2;
//MyCenter图片中心点,发亮此值会让强光中心发生偏移
Point MyCenter = new Point(MyWidth / 2, MyHeight / 2);
//R强光照射面的半径,即”光晕”
int R = Math.Min(MyWidth / 2, MyHeight / 2);
for (int i = MyWidth - 1; i >= 1; i--)
{
for (int j = MyHeight - 1; j >= 1; j--)
{
float MyLength = (float)Math.Sqrt(Math.Pow((i - MyCenter.X), 2) + Math.Pow((j - MyCenter.Y), 2));
//如果像素位于”光晕”之内
if (MyLength < R)
{
Color MyColor = MyImage.GetPixel(i, j);
int r, g, b;
//220亮度增加常量,该值越大,光亮度越强
float MyPixel = 220.0f * (1.0f - MyLength / R);
r = MyColor.R + (int)MyPixel;
r = Math.Max(0, Math.Min(r, 255));
g = MyColor.G + (int)MyPixel;
g = Math.Max(0, Math.Min(g, 255));
b = MyColor.B + (int)MyPixel;
b = Math.Max(0, Math.Min(b, 255));
//将增亮后的像素值回写到位图
Color MyNewColor = Color.FromArgb(255, r, g, b);
MyImage.SetPixel(i, j, MyNewColor);
}
}
}
//重新绘制图片
MyGraphics.DrawImage(MyImage, new Rectangle(0, 0, MyWidth, MyHeight));


由于该方法就是计算每一个像素点的,效率不高,不适用于大图像的显示

再处理鼠标离开事件,当鼠标离开后再恢复原图
nearthesun 2009-01-28
  • 打赏
  • 举报
回复
这个我是知道的~我其实问的是~怎么产生特效~比如放大或者加亮~~~
GkfSyser 2009-01-26
  • 打赏
  • 举报
回复
设置pictureBox的MouseEnter事件

111,131

社区成员

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

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

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