使用C#解析XMIND文件格式
static void Main(string[] args)
{
var tempPath = @"c:\Temp"; if (Directory.Exists(tempPath))
{
Directory.Delete(tempPath,true);
}
Directory.CreateDirectory(tempPath); ZipFile.ExtractToDirectory(@"c:\test.xmind", tempPath); //缩略图地址
var thumbPath = tempPath + "\\Thumbnails\\thumbnail.png";
var targetThumbPath = tempPath + "\\Thumbnails\\160X120.png";
var fi=new FileInfo(targetThumbPath);
if (fi.Exists)
{
fi.IsReadOnly = false;
fi.Delete();
}
int width;
int height;
ThumbImage.GetMicroImage(thumbPath, targetThumbPath, , , out width, out height);
Console.WriteLine("缩略图:"+ targetThumbPath);
Console.WriteLine("预览图:" + thumbPath + " 原图宽:" + width + ",原图高:" + height);
//附件
var attachmentsPath = new DirectoryInfo(tempPath + "\\attachments");
var count = ;
foreach (var o in attachmentsPath.GetFiles())
{
count++;
Console.WriteLine("附件"+count+" : "+o.Name);
} Console.WriteLine("成功!");
Console.ReadKey();
}
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging; namespace ConsoleApplication2
{
internal class ThumbImage
{
/// <summary>
/// 高质量缩放图片
/// </summary>
/// <param name="originFilePath">源图的路径</param>
/// <param name="targetFilePath">存储缩略图的路径</param>
/// <param name="destWidth">缩放后图片宽度</param>
/// <param name="destHeight">缩放后图片高度</param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns>表明此次操作是否成功</returns>
public static bool GetMicroImage(string originFilePath, string targetFilePath, int destWidth, int destHeight,
out int width, out int height)
{
width = ;
height = ;
try
{
using (Image imgSource = new Bitmap(originFilePath))
{
width = imgSource.Width;
height = imgSource.Height;
//System.Drawing.Image imgSource = b;
int sW = , sH = ;
// 按比例缩放
var sWidth = imgSource.Width;
var sHeight = imgSource.Height;
if (sHeight > destHeight || sWidth > destWidth)
{
if ((sWidth*destHeight) > (sHeight*destWidth))
{
sW = destWidth;
sH = (destWidth*sHeight)/sWidth;
}
else
{
sH = destHeight;
sW = (sWidth*destHeight)/sHeight;
}
}
else
{
sW = sWidth;
sH = sHeight;
}
var outBmp = new Bitmap(destWidth, destHeight);
var g = Graphics.FromImage(outBmp);
g.Clear(Color.Transparent);
// 设置画布的描绘质量
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(imgSource, new Rectangle((destWidth - sW)/, (destHeight - sH)/, sW, sH), , ,
imgSource.Width, imgSource.Height, GraphicsUnit.Pixel);
g.Dispose();
// 以下代码为保存图片时,设置压缩质量
var encoderParams = new EncoderParameters();
var quality = new long[];
quality[] = ;
var encoderParam = new EncoderParameter(Encoder.Quality, quality);
encoderParams.Param[] = encoderParam;
outBmp.Save(targetFilePath);
outBmp.Dispose();
}
//压缩一下PNG图
//CompressPng(targetFilePath, targetFilePath); return true;
}
catch (Exception)
{
return false;
}
}
}
}
使用C#解析XMIND文件格式的更多相关文章
- Python解析Xmind工具
使用Xmind写用例 使用Python解析Xmind,统计用例个数 代码: from xmindparser import xmind_to_dict import tkinter as tk fro ...
- 用Python解析XMind
本文来自网易云社区 作者:孙圣翔 转自:http://shengxiang.me/article/35/python-parse-xmind.html XMind是画思维脑图很好的工具,正好组里有个需 ...
- 时序数据库 Apache-IoTDB 源码解析之文件格式简介(三)
上一章聊到在车联网或物联网中对数据库的需求,以及 IoTDB 的整体架构,详情请见: 时序数据库 Apache-IoTDB 源码解析之系统架构(二) 打一波广告,欢迎大家访问IoTDB 仓库,求一波 ...
- 提效工具-python解析xmind文件及xmind用例统计
现状 每个公司都有一个维护测试case的系统,有自研的也有买的,比如QC, 禅道等等,QA往往习惯使用xmind等思维导图工具来编写测试用例,因为思路清晰,编写方便,那么这就有一个问题,大多公司要求所 ...
- MFC里面解析json文件格式
CString strTemp; //CString ->string; string stringMsg = (LPCSTR)(CStringA)strTemp; //string -> ...
- python 解析top文件格式
top - 16:14:35 up 2 days, 3:04, 7 users, load average: 2.22, 1.84, 1.77 Tasks: 512 total, 2 running, ...
- Dotnet文件格式解析
0x0.序 解析过程并没有介绍对pe结构的相关解析过程,网上此类相关资料很多可自行查阅,本文只介绍了网上资料较少的从pe结构的可选头中的数据目录表中获取dotnet目录的rva和size,到完全解析d ...
- wav音频文件格式解析【个人笔记】(自用)
1. WAV格式 wav是微软开发的一种音频文件格式,注意,wav文件格式是无损音频文件格式,相对于其他音频格式文件数据是没有经过压缩的,通常文件也相对比较大些.. 支持多种音频数字,取样频率和声道, ...
- mp4文件格式解析(转)
mp4文件格式解析 MP4文件格式带数据详解 MP4文件格式的解析,以及MP4文件的分割算法
随机推荐
- django FBV +CBV 视图处理方式总结
1.FBV(function base views) 在视图里使用函数处理请求. url: re_path('fbv', views.fbv), # url(r'^fbv' ...
- UE4 Pro Tips(keeps updating)
Consolidate 功能 :在工程范围内用一种资源替换另外一种或多种资源具体操作:同时在编辑器中选中两个或多个资源,右键>Asset Actions>Replace Reference ...
- 170906-MyBatis续
===============================================Dynamic SQL========================================== ...
- Springboot-H2DB
为什么在Springboot中用H2DB 用Springboot开发需要连接数据库的程序的时候,使用H2DB作为内存数据库可以很方便的调试程序. 怎么用 1.加入依赖 <dependency&g ...
- oracle触发器update本表数据
功能: 1. 允许/限制对表的修改 2. 自动生成派生列,比如自增字段 3. 强制数据一致性 4. 提供审计和日志记录 5. 防止无效的事务处理 6. 启用复杂的业务逻辑 开始 create trig ...
- nacos 使用 servlet 异步处理客户端配置长轮询
config 客户端 ClientWorker#ClientWorker 构造方法中启动定时任务 ClientWorker.LongPollingRunnable 长轮询的任务,在 run 方法的结尾 ...
- ensorflow学习笔记四:mnist实例--用简单的神经网络来训练和测试
http://www.cnblogs.com/denny402/p/5852983.html ensorflow学习笔记四:mnist实例--用简单的神经网络来训练和测试 刚开始学习tf时,我们从 ...
- 大数据架构师必读的NoSQL建模技术
大数据架构师必读的NoSQL建模技术 从数据建模的角度对NoSQL家族系统做了比较简单的比较,并简要介绍几种常见建模技术. 1.前言 为了适应大数据应用场景的要求,Hadoop以及NoSQL等与传统企 ...
- 神器 工具 推荐 SRDebugger
unity asset store 关联下载 ,添加这个书签 javascript:var url = window.location.href;var id = url.substr(url.la ...
- HTTP response status
The status code is a 3-digit number: 1xx (Informational): Request received, server is continuing the ...