private void ShowSelectedPicture(string path)
{
FileStream fs = File.OpenRead(path); //OpenRead
int filelength = ;
filelength = (int)fs.Length; //获得文件长度
Byte[] image = new Byte[filelength]; //建立一个字节数组
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource =new MemoryStream(image );
bitmapImage.EndInit();
var pictureWindow = new PictureWindow();//自己创建的窗口
pictureWindow.myImage.Source = bitmapImage;//myImage窗口中的图片空间
//pictureWindow.myImage.Width = bitmapImage.PixelWidth;
//pictureWindow.myImage.Height = bitmapImage.PixelHeight;
pictureWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
pictureWindow.ShowDialog();
}

private void MyImage_OnMouseWheel(object sender, MouseWheelEventArgs e)
    {
         double ScaleX = 0;
         double ScaleY = 0;
         double dbl_ZoomX = ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleX;
         double dbl_ZoomY = ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleY;
        ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).CenterX = e.GetPosition(this.myImage).X;
        ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).CenterY = e.GetPosition(this.myImage).Y;


if (e.Delta < 0)
       {
          ScaleX = dbl_ZoomX - 0.1 < 0.2 ? 0.1 : dbl_ZoomX - 0.1;
          ScaleY = dbl_ZoomY - 0.1 < 0.2 ? 0.1 : dbl_ZoomY - 0.1;
       }
     else if (e.Delta > 0)
     {
        ScaleX = dbl_ZoomX + 0.1 > 10.0 ? 10.0 : dbl_ZoomX + 0.1;
        ScaleY = dbl_ZoomY + 0.1 > 10.0 ? 10.0 : dbl_ZoomY + 0.1;
     }


((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleX = ScaleX;
       ((ScaleTransform)(((TransformGroup)(((UIElement)(this.myImage)).RenderTransform)).Children[0])).ScaleY = ScaleY;
    }

 

C# 上传图片

 private void UploadImage(string Path)
{
FileStream fullfs;
string pictureName = GetPictureName();
string pictureFullPath = storePath;// GetPicturePath(rtdto.BusinessIndex, rtdto.ProviderIndex);
string pictureFullName = pictureFullPath + @"\" + pictureName;
fullfs = new FileStream(pictureFullName, FileMode.Create);
BinaryWriter fullbw = new BinaryWriter(fullfs);
fullbw.Write(pidto.PictureData);
fullbw.Close();
fullfs.Close();
}
private string GetPicturePath(int businessindex, int providerindex)
{
string currentPath = AppDomain.CurrentDomain.BaseDirectory + @"\Image";
if (!System.IO.Directory.Exists(currentPath))
{
try
{
System.IO.Directory.CreateDirectory(currentPath);
}
catch
{
currentPath = AppDomain.CurrentDomain.BaseDirectory;//创建目录失败,存入根目录中
}
}
string filePath = currentPath + @"\" + businessindex + "_" + providerindex;
if (!System.IO.Directory.Exists(filePath))
{
try
{
System.IO.Directory.CreateDirectory(filePath);
}
catch
{
filePath = currentPath;//创建目录失败,存入根目录中
} }
return filePath;
}
private string GetPictureName()
{
string imageGuid = Guid.NewGuid().ToString() + ".jpg";
return imageGuid;
}

窗口页面代码

<Window x:Class="App.Modules.PictureWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:uiControls="clr-namespace:Allegion.Components.UIControls;assembly=Allegion.Components.UIControls"
Title="PictureWindow"> <ScrollViewer x:Name="scrollViewer"
HorizontalScrollBarVisibility="Auto"
MouseWheel="ScrollViewer_OnMouseWheel"
VerticalScrollBarVisibility="Auto"> <Image Name="myImage" MouseWheel="MyImage_OnMouseWheel">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="" ScaleY="" />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Image.RenderTransform>
</Image>
</ScrollViewer>
</Window>

C# 弹出窗口查看图片以及上传图片的更多相关文章

  1. jQuery弹出窗口浏览图片

    效果预览:http://keleyi.com/keleyi/phtml/jqtexiao/3.htm HTML文件代码: <!DOCTYPE HTML> <html> < ...

  2. chrome浏览器上传图片反应很慢,延迟很久才弹出窗口

    chrome浏览器上传图片反应很慢,延迟很久才弹出窗口 一个上传图片的控件,点击按钮上传图片,用chrome(谷歌浏览器)时,点击按钮后,要等好几秒才弹出文件选择窗口 可以试一下,把网络断开,这个问题 ...

  3. jQuery弹出窗口完整代码

    jQuery弹出窗口完整代码 效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/1.htm 1 <!DOCTYPE html PUBLIC "- ...

  4. jQuery插件---轻量级的弹出窗口wBox

    Box Demo wBox——轻量级的弹出窗口jQuery插件,基于jQuery1.4.2开发,主要实现弹出框的效果,并且加入了很多有趣的功能,比如可img灯箱效果,callback函数,显示隐藏层, ...

  5. OAF_开发系列08_实现OAF通过Popup参数式弹出窗口(案例)

    20150711 Created By BaoXinjian

  6. ArcGIS API for Silverlight 当DataGrid选中项时,地图聚焦弹出窗口,并可以播放音频文件

    原文:ArcGIS API for Silverlight 当DataGrid选中项时,地图聚焦弹出窗口,并可以播放音频文件 先看效果图,然后上代码: <UserControl x:Class= ...

  7. js弹出窗口的学习和使用

    Thickbox Thickbox是基于Jquery的,因此使用Thickbox需要下面四个文件: Thickbox.js----Thickbox主文件 CSS文件----Thickbox.css 最 ...

  8. [selenium webdriver Java]处理弹出窗口

    Selenium WebDriver测试弹出窗口,包括识别弹出窗口,将driver转到新的窗口,在新的串钩中执行而是步骤,然后再转换到最初的窗口. 通过名称(name)识别和处理: Selenium ...

  9. Win8 弹出窗口不在最前端的解决方法

    Win8系统的使用者有很多会遇到弹出窗口不在最前端的情况(自动隐藏,点下页面又出来),比如另存为的时候 ,或是登录路由器时弹出的登录框时. 引起这个异常的原因是与系统输入法冲突引起,但又不可能不用第三 ...

随机推荐

  1. OpenCV-Python教程(10、直方图均衡化)

    相比C++而言,Python适合做原型.本系列的文章介绍如何在Python中用OpenCV图形库,以及与C++调用相应OpenCV函数的不同之处.这篇文章介绍在Python中使用OpenCV和NumP ...

  2. UVA - 10131Is Bigger Smarter?(DAG上的DP)

    题目:UVA - 10131Is Bigger Smarter? (DAG) 题目大意:给出一群大象的体重和IQ.要求挑选最多的大象,组成一个序列.严格的体重递增,IQ递减的序列.输出最多的大象数目和 ...

  3. 【MFC学习笔记-作业6-sin图像】【OnDraw(CDC* pDC)】

    根据这段源代码 一步一步剖析CDC的使用 void CDrawSinXView::OnDraw(CDC* pDC) { CDrawSinXDoc* pDoc = GetDocument(); ASSE ...

  4. T-SQL存储过程

    存储过程(procedure)就是一个函数,完成一段sql代码的封装,实现代码的重用.    优点:         1.比使用DotNet直接写Sql脚本执行少了一块解析编译的过程.效率更快一点点. ...

  5. jQuery--checkbox全选/取消全选

    用JavaScript使页面上的一组checkbox全选/取消全选,逻辑很简单,实现代码也没有太难的语法.但使用jQuery实现则更简单,代码也很简洁,精辟! jQuery版本:1.3.2 <h ...

  6. servlet+ajax+json字符串后台传入,前端解析并把数据循环填入表格实例

    写在前面:1.源代码来源于博客http://blog.sina.com.cn/u/2904067371 ,在此基础上对于前端代码稍作更改,把传过来的数据解析并传入表格2.json解析,用eval()3 ...

  7. 获取json对象长度

    JSON对象变化万千,非常灵活,对应的获取方法分别为: 1.最简单类型的(myObject是对象,不是字符串哦) <script type="text/javascript" ...

  8. js、jquery、css使用过程中学到的一些方法技巧

    快速查看 1 动态创建script/link/style标签 2 在不适合使用iframe的情况下,让页面像iframe那样能分块滚动 3  鼠标在元素上时显示tip风格的提示信息 1.动态创建scr ...

  9. 十个最值得阅读学习的C开源项目代码

    1. Webbench Webbench 是一个在linux下使用的非常简单的网站压测工具.它使用fork()模拟多个客户端同时访问我们设定的URL,测试网站在压力下工作的性能,最多可以 模拟3万个并 ...

  10. js数组的操作<转>

    转自 http://blog.csdn.net/xcxinghai/article/details/13502583 PS(个人理解): 1) 数组项的数据类型可以是混合多样的,同时可以含string ...