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. 呵呵!手把手带你在 IIS 上执行 Python

    公司的站点让我头痛死了.在众多前辈高手的带领下.一大堆的 CMD 在站点里执行得好好地,黑客攻击也好好地.仅仅有站点和我不好好地,我快累死了,站点快挂了.. . 为了解决问题.我想到了 Python ...

  2. Swift主题色顶级解决方案

    一.常规主题色使用点 应用在发布前都会对主题色进行设置,以统一应用的风格(可能有多套主题).在主题色设置上有几个方面,如下: 1. TabBar部分,设置图片高亮.文本高度颜色2. Navigatio ...

  3. asp.net application

    Application 对象用于存储和访问来自任何页面的变量,类似于 session 对象.不同之处在于,所有的用户分享一个 Application 对象,而 session 对象和用户的关系是一一对 ...

  4. 数据库————Select 查询

    --创建mydb数据库create database mydb go --使用数据库use mydb go --水果表 create table Fruit ( Ids varchar() prima ...

  5. L9-2.安装mysql数据库

    二.安装mysql 1.检查是否安装了mysql 2.安装cmake 输入gmake: make install 安装依赖的软件包: 新建用户权限等: 解压 安装 安装: 安装成功. 安装后调整: v ...

  6. iOS学习心得——UITableViewCell的复用

    UITableView是在iOS开发中最常用的控件之一.我的第一篇学习心得献给它了         UITableView是由一行一行的UITableViewCell构成的.         首先想这 ...

  7. [string]Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...

  8. yum node.js

    很久之前安装过windows下以及Mac下的node,感觉还是很方便的,不成想今天安装linux下的坑了老半天,特此记录. 首先去官网下载代码,这里一定要注意安装分两种,一种是Source Code源 ...

  9. js删除数组里的某个元素

    首先可以给js的数组对象定义一个函数,用于查找指定的元素在数组中的位置,即索引,代码为: Array.prototype.indexOf = function(val) { for (var i = ...

  10. html5的video标签支持的视频格式