cif 图片格式转换工具的用法:
cif source_file dest_file [width] [height]
参数说明:
source_file: 原始图片
dest_file: 目的图片
width 目的图片的宽度
height 目的图片的高度
eg.
cif foo.png foo.ico
cif foo.png foo.ico 100 200
cif foo.jpg foo.png
c++源码:
#include <iostream>
#include <string>
#include "..\CxImage\ximage.h"
std::string GetFileExtension(const std::string& strPath)
{
size_t nPot = strPath.rfind(".");
if (nPot == std::string::npos)
{
return "";
}
return strPath.substr(nPot + 1,strPath.length() - nPot - 1);
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3)
{
std::cout<<" please input : cif source_file dest_file [width] [height] "<<std::endl;
return 1;
}
std::string strExt;
strExt = GetFileExtension(argv[1]);
CxImage image;
image.Load(argv[1],CxImage::GetTypeIdFromName(strExt.c_str()));
if (!image.IsValid())
{
std::cout<<" src image is invalid! "<<std::endl;
return 1;
}
if (argc == 5)
{
image.Resample(atoi(argv[3]),atoi(argv[4]),0);
}
strExt = GetFileExtension(argv[2]);
image.Save(argv[2],CxImage::GetTypeIdFromName(strExt.c_str()));
return 0;
}
依赖的库:
cif source_file dest_file [width] [height]
参数说明:
source_file: 原始图片
dest_file: 目的图片
width 目的图片的宽度
height 目的图片的高度
eg.
cif foo.png foo.ico
cif foo.png foo.ico 100 200
cif foo.jpg foo.png
c++源码:
#include <iostream>
#include <string>
#include "..\CxImage\ximage.h"
std::string GetFileExtension(const std::string& strPath)
{
size_t nPot = strPath.rfind(".");
if (nPot == std::string::npos)
{
return "";
}
return strPath.substr(nPot + 1,strPath.length() - nPot - 1);
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3)
{
std::cout<<" please input : cif source_file dest_file [width] [height] "<<std::endl;
return 1;
}
std::string strExt;
strExt = GetFileExtension(argv[1]);
CxImage image;
image.Load(argv[1],CxImage::GetTypeIdFromName(strExt.c_str()));
if (!image.IsValid())
{
std::cout<<" src image is invalid! "<<std::endl;
return 1;
}
if (argc == 5)
{
image.Resample(atoi(argv[3]),atoi(argv[4]),0);
}
strExt = GetFileExtension(argv[2]);
image.Save(argv[2],CxImage::GetTypeIdFromName(strExt.c_str()));
return 0;
}
依赖的库:
CxImage库下载地址: http://www.codeproject.com/Articles/1300/CxImage
程序下载地址:
http://download.csdn.net/download/bubuchrome/4948836