怎么为我的图像浏览器加上动态显示效果

zhu890103 2009-05-27 08:35:42
我有一个图像浏览器,想加上动态显示效果。。
应该怎么添加。。动态显示就是指 垂直百叶窗 上下翻转显示 以分块效果显示 等

动态显示的程序我都有。。他们上边用PICBOX显示的。。但是我的图像浏览器 是 通过子父窗体显示

没有PICBOX 应该怎么添加 进去我的浏览器里。。。。

想的是 让他单击打开 点确定的时候 就动态显示图像

资源在http://download.csdn.net/source/1355037

和http://download.csdn.net/source/1355039

下载下来把这2个结合1下。。
麻烦看看了

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BrownImage4
{
public partial class frmMain : Form
{

frmSub frmsub;

public frmMain()
{
InitializeComponent();
}

//当前子窗口被激活成为当前窗口时
private void frmMain_MdiChildActivate(object sender, EventArgs e)
{
frmsub = (frmSub)this.ActiveMdiChild; //设置当前激活的子窗口
if (frmsub != null)
{
//设置状态栏内容
tssFile.Text = frmsub.picImage.ImageLocation;
tssZoom.Text = "缩放:" + (int)(frmsub.picImage.Width * 100 / frmsub.picImage.Image.Width) + "%";
}
else
toolsNoEnable(); //如果没有子窗口,则禁用工具栏和菜单的相关项
}

//当主窗体加载时,设置工具栏、菜单栏状态
private void frmMain_Load(object sender, EventArgs e)
{
toolsNoEnable(); //调用toolsNoEnable()设置工具栏、菜单栏状态
}

//单击“层叠”菜单命令时
private void 层叠ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.Cascade); //层叠子窗口
}

//单击“垂直平铺”菜单命令时
private void 垂直平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);//垂直平铺子窗口
}
//单击“水平平铺”菜单命令时
private void 水平平铺ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.LayoutMdi(MdiLayout.TileHorizontal);//水平平铺子窗口
}

//单击“打开”菜单命令
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFile();
}

//单击“退出”菜单命令
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
AppExit();
}

//单击工具栏上的打开文件按钮
private void tsbOpen_Click(object sender, EventArgs e)
{
OpenFile();
}

//单击工具栏中的退出按钮
private void tsbExit_Click(object sender, EventArgs e)
{
AppExit();
}

//单击工具栏中的放大按钮
private void tsbOut_Click(object sender, EventArgs e)
{
ZoomOut();
}

//单击工具栏中的缩小按钮
private void tsbIn_Click(object sender, EventArgs e)
{
ZoomIn();
}

//单击工具栏中的原图大小按钮
private void tsbOrg_Click(object sender, EventArgs e)
{
ZoomOrg();
}

//单击“原图”菜单命令时
private void 原图ToolStripMenuItem_Click(object sender, EventArgs e)
{
ZoomOrg();
}

//单击“放大”菜单命令时
private void 放大ToolStripMenuItem_Click(object sender, EventArgs e)
{
ZoomOut();
}

//单击“缩小”菜单命令时
private void 缩小ToolStripMenuItem_Click(object sender, EventArgs e)
{
ZoomIn();
}

//当在组合框中输入数值并回车时
private void tsbMultiples_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyValue == 13) //如果按下回车键
{
Zoom();
}
}

//当工具栏中的组合框当前项索引改变时
private void tsbMultiples_SelectedIndexChanged(object sender, EventArgs e)
{
Zoom();
}

//自定义函数Openfrmsub.ile()用于打开图像文件
private void OpenFile()
{
//设置文件过滤
openFileDialog1.Filter = "所有图像文件|*.jpg;*.jpeg;*.bmp;*.gif;*.tif;*.wmf|BMP位图(*.bmp)|*.bmp|JPEG图像 (*.jpg)|*.jpg;*.jpeg|图元文件 (*.wmf)|*.wmf|GIf.图像 (*.gif)|*.gif|所有文件|*.*";
openFileDialog1.AddExtension = true;
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
//打开“打开文件”对话框
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
frmsub = new frmSub(); //创建新子窗体
frmsub.MdiParent = this; //设置子窗体的父窗体为当前窗体
frmsub.Show(); //显示子窗体
frmsub.picImage.Load(openFileDialog1.FileName); //载入文件到子窗口

//设置子窗口内容
frmsub.picImage.Width = frmsub.picImage.Image.Width;
frmsub.picImage.Height = frmsub.picImage.Image.Height;
frmsub.Text = openFileDialog1.FileName;
frmsub.ImgLayout();

//设置工具栏、菜单栏状态
toolsEnable();
}


}

//自定义函数AppExit()用于退出程序
private void AppExit()
{
Application.Exit(); //退出当前应用程序
}

//自定义函数ZoomOut()用于放大图像
private void ZoomOut()
{
frmsub.picImage.Width = (int)(frmsub.picImage.Width * 1.2);
frmsub.picImage.Height = (int)(frmsub.picImage.Height * 1.2);
tssZoom.Text = "缩放:" + (int)(frmsub.picImage.Width * 100 /frmsub.picImage.Image.Width) + "%";
frmsub.ImgLayout();
}

//自定义函数ZoomIn()用于缩小图像
private void ZoomIn()
{
frmsub.picImage.Width = (int)(frmsub.picImage.Width / 1.2);
frmsub.picImage.Height = (int)(frmsub.picImage.Height / 1.2);
tssZoom.Text = "缩放:" + (int)(frmsub.picImage.Width * 100 / frmsub.picImage.Image.Width) + "%";
frmsub.ImgLayout();
}

//自定义函数ZoomOrg()用于设置图像为原图大小
private void ZoomOrg()
{
frmsub.picImage.Width = (int)frmsub.picImage.Image.Width;
frmsub.picImage.Height = (int)frmsub.picImage.Image.Height;
tssZoom.Text = "缩放:100%";
frmsub.ImgLayout();
}

////自定义函数Zoom()用于设置图像为指定大小
private void Zoom()
{
frmsub.picImage.Width = (int)(frmsub.picImage.Image.Width * Convert.ToInt16(tsbMultiples.Text) / 100);
frmsub.picImage.Height = (int)(frmsub.picImage.Image.Height * Convert.ToInt16(tsbMultiples.Text) / 100);
tssZoom.Text = "缩放:" + (int)(frmsub.picImage.Width * 100 / frmsub.picImage.Image.Width) + "%";
frmsub.ImgLayout();
}

//自定义函数toolsEnable()用于设置在有图像文件被打开时的工具栏、菜单栏状态
private void toolsEnable()
{
//设置工具栏按钮可用
tsbExit.Enabled = true;
tsbIn.Enabled = true;
tsbOrg.Enabled = true;
tsbMultiples.Enabled = true;
tsbOut.Enabled = true;

//设置状态栏内容
tssFile.Text = openFileDialog1.FileName; //设置状态栏的文件路径
tssZoom.Text = "缩放:100%";

//设置“窗口”菜单和“视图”菜单可用
窗口ToolStripMenuItem.Enabled = true;
视图ToolStripMenuItem.Enabled = true;

}

//自定义函数toolsNoEnable()用于设置在没有图像文件被打开时的工具栏、菜单栏状态
private void toolsNoEnable()
{
//设置工具栏不可用的按钮
tsbExit.Enabled = false;
tsbIn.Enabled = false;
tsbOrg.Enabled = false;
tsbOut.Enabled = false;
tsbMultiples.Enabled =false;

//设置状态栏内容
tssZoom.Text = "";
tssFile.Text = "";

//设置“窗口”菜单和“视图”菜单不可用
窗口ToolStripMenuItem.Enabled = false;
视图ToolStripMenuItem.Enabled = false;
}
}
}
图像浏览器的代码
...全文
177 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaojing7 2009-05-29
  • 打赏
  • 举报
回复
GDI+
zhu890103 2009-05-27
  • 打赏
  • 举报
回复
俺们要求是 C#做。。。--!
yong469546396 2009-05-27
  • 打赏
  • 举报
回复
用JavaScript也能实现啊!
<SCRIPT>
<!--
transeffect = 0;
theeffects = new Array(24);
theeffects[0] = "盒状收缩";
theeffects[1] = "盒状向外";
theeffects[2] = "圆形收缩";
theeffects[3] = "圆形向内";
theeffects[4] = "从下向上";
theeffects[5] = "从上向下";
theeffects[6] = "从左向右";
theeffects[7] = "从右向左";
theeffects[8] = "百页窗形向右";
theeffects[9] = "百页窗形向下";
theeffects[10] = "棋盘形交叉向右";
theeffects[11] = "棋盘形交叉向下";
theeffects[12] = "随意溶解形";
theeffects[13] = "左右向内";
theeffects[14] = "左右向外";
theeffects[15] = "上下向内";
theeffects[16] = "上下向外";
theeffects[17] = "条纹状向左下";
theeffects[18] = "条纹状向左上";
theeffects[19] = "条纹状向右下";
theeffects[20] = "条纹状向右上";
theeffects[21] = "溶解水平状";
theeffects[22] = "溶解上下状";
theeffects[23] = "随着溶解";
current_image = "image1";
function Clicked() {
var the_image, the_other;
text2.style.visiblity="hidden";
if (image1.style.visibility=="inherit") {
the_image = image2;
the_other = image1;
}
else {
the_image = image1;
the_other = image2;
}
the_other.style.visibility="hidden";
the_image.filters.item(0).Apply();
the_image.filters.item(0).Transition = transeffect;
the_image.filters.item(0).Play(2.0);
the_image.style.visibility="inherit";
text2.innerText=theeffects[transeffect];
transeffect++;
if (transeffect == 24)
transeffect = 0;
text2.style.visibility="visible";
}
//-->
</SCRIPT>
<DIV id=image>
<DIV id=text1></DIV><IMG id=image1
src="images/logo.gif"
style="FILTER: revealTrans(Duration=3.0,Transition=1); VISIBILITY: hidden"> <IMG id=image2 src="Pioneer/Pioneer/Image/1.jpg"
style="FILTER: revealTrans(Duration=3.0,Transition=1); VISIBILITY: hidden"> </DIV>
<DIV id=text2></DIV>

<body bgcolor="#fef4d9" onclick=Clicked()>
zhu890103 2009-05-27
  • 打赏
  • 举报
回复
动态显示的代码在下边

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
private Bitmap SourceBitmap;
private Bitmap MyBitmap;

public Form1()
{
InitializeComponent();
}

private void btnQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void btnOpen_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
SourceBitmap = new Bitmap(openFileDialog1.FileName);
MyBitmap = new Bitmap(SourceBitmap, this.pictureBox1.Width, this.pictureBox1.Height);

this.pictureBox1.Image = MyBitmap;
int width = this.MyBitmap.Width; //图像宽度
int height = this.MyBitmap.Height; //图像高度
Graphics g = this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);

for (int i = -width / 2; i <= width / 2; i++)
{
//g.Clear(Color.Gray);
//int j = Convert.ToInt32(i * (Convert.ToSingle(height) / Convert.ToSingle(width)));

//Rectangle DestRect = new Rectangle(0, height / 2 - j, width, 2 * j);
//Rectangle SrcRect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height);

//g.DrawImage(MyBitmap, DestRect, SrcRect, GraphicsUnit.Pixel);
//System.Threading.Thread.Sleep(10);

//双缓存技术解决图像的闪烁问题
int j = Convert.ToInt32(i * (Convert.ToSingle(height) / Convert.ToSingle(width)));

Rectangle DestRect = new Rectangle(0, height / 2 - j, width, 2 * j);
Rectangle SrcRect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height);

Bitmap localBitmap = new Bitmap(pictureBox1.ClientRectangle.Width,
pictureBox1.ClientRectangle.Height);
Graphics bitmapGraphics = Graphics.FromImage(localBitmap);

bitmapGraphics.Clear(Color.Gray);
bitmapGraphics.DrawImage(MyBitmap, DestRect, SrcRect, GraphicsUnit.Pixel);
g.DrawImage(localBitmap, 0, 0);
System.Threading.Thread.Sleep(10);
}
g.Dispose();
}
}
}
}

2个结合下。。。怎么结合

110,537

社区成员

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

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

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