//创建时间2015年5月26日
//使用到的函数原型:
// 1、 IplImage* cvLoadImage( const char* filename, int flags=CV_LOAD_IMAGE_COLOR );
// 2、 IplImage* cvCreateImage( CvSize size, int depth, int channels );
// 3、 void cvResize( const CvArr* src, CvArr* dst, int interpolation=CV_INTER_LINEAR );
//明天加一个读取文件保护措施。(读取图像不成功地)
//收获:1、文件读取在E:\Program Files\visual studio text\ImageZoom\ImageZoom这个文件夹中
// 2、预编译头文件stdafx.h属性中已经包含,不需要重复包含。
// 3、隐藏控制台程序代码:#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
#include "cv.h"
#include "highgui.h"
using namespace std;
//隐藏控制台
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main ()
{
const char * pstrImageName = "华山论剑.JPG";
const char * pstrSaveImageName = "华山论剑缩放图.JPG";
const char * patrWindowsSrcTitle = "华山论剑原图";
const char * patrWinsowsDstTitle = "华山论剑缩放图";
double fScale = 0.314;
CvSize cvsize;
IplImage * pSrcImage = cvLoadImage( pstrImageName , CV_LOAD_IMAGE_COLOR );
if( pSrcImage == 0)
{
cout<<"图片载入失败!"<<endl;
return -1;
}
IplImage * pDstImage = NULL;
cvsize.width = pSrcImage->width * fScale;
cvsize.height = pSrcImage->height * fScale;
pDstImage = cvCreateImage( cvsize , pSrcImage->depth , pSrcImage->nChannels );
cvResize( pSrcImage , pDstImage , CV_INTER_AREA );
cvNamedWindow( patrWindowsSrcTitle , CV_WINDOW_AUTOSIZE );
cvNamedWindow( patrWinsowsDstTitle , CV_WINDOW_AUTOSIZE );
cvShowImage( patrWindowsSrcTitle , pSrcImage );
cvShowImage( patrWinsowsDstTitle , pDstImage );
cvWaitKey();
cvSaveImage ( pstrSaveImageName , pDstImage);
cvDestroyWindow( patrWindowsSrcTitle );
cvDestroyWindow( patrWinsowsDstTitle );
cvReleaseImage( &pSrcImage );
cvReleaseImage( &pDstImage );
return 0;
}
//使用到的函数原型:
// 1、 IplImage* cvLoadImage( const char* filename, int flags=CV_LOAD_IMAGE_COLOR );
// 2、 IplImage* cvCreateImage( CvSize size, int depth, int channels );
// 3、 void cvResize( const CvArr* src, CvArr* dst, int interpolation=CV_INTER_LINEAR );
//明天加一个读取文件保护措施。(读取图像不成功地)
//收获:1、文件读取在E:\Program Files\visual studio text\ImageZoom\ImageZoom这个文件夹中
// 2、预编译头文件stdafx.h属性中已经包含,不需要重复包含。
// 3、隐藏控制台程序代码:#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
#include "cv.h"
#include "highgui.h"
using namespace std;
//隐藏控制台
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main ()
{
const char * pstrImageName = "华山论剑.JPG";
const char * pstrSaveImageName = "华山论剑缩放图.JPG";
const char * patrWindowsSrcTitle = "华山论剑原图";
const char * patrWinsowsDstTitle = "华山论剑缩放图";
double fScale = 0.314;
CvSize cvsize;
IplImage * pSrcImage = cvLoadImage( pstrImageName , CV_LOAD_IMAGE_COLOR );
if( pSrcImage == 0)
{
cout<<"图片载入失败!"<<endl;
return -1;
}
IplImage * pDstImage = NULL;
cvsize.width = pSrcImage->width * fScale;
cvsize.height = pSrcImage->height * fScale;
pDstImage = cvCreateImage( cvsize , pSrcImage->depth , pSrcImage->nChannels );
cvResize( pSrcImage , pDstImage , CV_INTER_AREA );
cvNamedWindow( patrWindowsSrcTitle , CV_WINDOW_AUTOSIZE );
cvNamedWindow( patrWinsowsDstTitle , CV_WINDOW_AUTOSIZE );
cvShowImage( patrWindowsSrcTitle , pSrcImage );
cvShowImage( patrWinsowsDstTitle , pDstImage );
cvWaitKey();
cvSaveImage ( pstrSaveImageName , pDstImage);
cvDestroyWindow( patrWindowsSrcTitle );
cvDestroyWindow( patrWinsowsDstTitle );
cvReleaseImage( &pSrcImage );
cvReleaseImage( &pDstImage );
return 0;
}