eps文件是可以通过记事本打开的
其中BoundingBox表示的是eps文件的大小,(0,0)表示的是左下角的坐标,(324 ,226)表示的是右上角的坐标。
坐标的大小表示单位是像素,所以我们要转化为英寸,再转化为mm输出,看你个人需求了,我这次用的mm输出。eps
文件的编码方式是ASCii码。
通过编程获得.eps文件的高度跟宽度。
vs2010下跑通代码
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;
template<class out_type,class in_value>
out_type convert(const in_value & t)
{
stringstream str;
str<<t;
out_type result;
str>>result;
return result;
}
template<class out_type,class in_value>
out_type convert(const in_value & t,bool bISWSring) //转wchar,wstring要用到这个
{
wstringstream str;
str<<t;
out_type result;
str>>result;
return result;
}
int main()
{
string filename;
cin>>filename;
string text;
string str;
fstream in(filename.c_str());
int nFlag;
if(!in)
{
cout<<"error"<<endl;
}
for (int i=0;i<10;i++) //获取Box那一行字符串
{
getline(in,text);
if(text[2]=='B'&&text[3]=='o')
{
break;
}
}
string box[4];
int t=15;
for(int i=0;i<4;i++)//提取四个坐标
{
int j;
for(j=t;j<text.length();j++)
{
if(text[j]==' ')
{
break;
}
box[i].push_back(text[j]);
}
t=j+1;
}
for(int i=0;i<4;i++)
{
cout<<box[i]<<endl;
}
double a[4];
for(int i=0;i<4;i++)
{
a[i]=convert<double>(box[i]);
}
for(int i=0;i<4;i++)
{
cout<<a[i]<<endl;
}
double width,height;
width=(a[2]-a[0])/72*25.4;
height=(a[3]-a[1])/72*25.4;
cout<<"width:"<<width<<endl;
cout<<"height"<<height<<endl;
cout<<text<<endl;
return 0;
}
这个程序也用到了我原来写的任意转化数据类型的模板