コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: hywei/Parameterization
void MainWindow::createActions()
{
	// file menu actions
	openModelAct = new QAction(QIcon("../images/open.png"), tr("&Open Model"), this);
	openModelAct->setShortcut(QKeySequence::New);
	openModelAct->setStatusTip(tr("open a mesh model"));
	connect(openModelAct, SIGNAL(triggered()), this, SLOT(openModel()));

	openTextureFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Texture Image"), this);
	connect(openTextureFileAct, SIGNAL(triggered()), this, SLOT(openTextureImage()));

	openQuadFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Quad File"), this);
	connect(openQuadFileAct, SIGNAL(triggered()), this, SLOT(openQuadFile()));

	saveModelAct = new QAction(QIcon("../images/save.png"), tr("&Save Model"), this);
	saveModelAct->setShortcut(QKeySequence::Save);
	saveModelAct->setStatusTip(tr("save this mesh model"));
	connect(saveModelAct, SIGNAL(triggered()), this, SLOT(saveModel()));

	saveAsBmpAct = new QAction(tr("Save as BMP"), this);
	connect(saveAsBmpAct, SIGNAL(triggered()), this, SLOT(saveAsBmp()));

	recentFileAct = new QAction(tr("Recent Files"), this);
	connect(recentFileAct, SIGNAL(triggered()), this, SLOT(recentFiles()));

	exitAct = new QAction(tr("E&xit"), this);
	exitAct->setShortcuts(QKeySequence::Quit);
	exitAct->setStatusTip(tr("Exit the application"));
	connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));


	// toolbar menu actions
	toolBarAct = new QAction(tr("ToolBar"), this);
	connect(toolBarAct, SIGNAL(triggered()), this, SLOT(toobBar()));

	stateBarAct = new QAction(tr("StateBar"), this);
	connect(stateBarAct, SIGNAL(triggered()), this, SLOT(stateBar()));

	// quad menu actions
	
	// help menu actions
	aboutAct = new QAction(tr("About"), this);
	connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));



	// mouse actions
	mouseSpinAct = new QAction(QIcon("../images/rotate-left.png"), tr("Spin"), this);
	connect(mouseSpinAct, SIGNAL(triggered()), this, SLOT(mouseSpin()));

	mouseMoveAct = new QAction(QIcon("../images/move.png"), tr("Move"), this);
	connect(mouseMoveAct, SIGNAL(triggered()), this, SLOT(mouseMove()));

	mouseZoomAct = new QAction(QIcon("../images/zoom.png"), tr("Zoom"), this);
	connect(mouseZoomAct, SIGNAL(triggered()), this, SLOT(mouseZoom()));

}
コード例 #2
0
/**************************************************************************
裁边函数3
void output3(PBYTE data,int width,int height,char *out)
PBYTE data:			图像数据
int width:			图像宽度
int height:		图像高度
char *out:			输出路径
**************************************************************************/
extern "C" __declspec(dllexport) void output3(PBYTE data,int width,int height,char *out){
	
	int nAdjust24 = width*3%4;
	if (nAdjust24) nAdjust24 = 4-nAdjust24;
	BYTE * data_T = new BYTE[(width*3+nAdjust24)*height];


	//改变顺序
	for (int j=0;j < height;j++){
		for (int i = 0;i< width;i++){
			data_T[j*(width*3+nAdjust24)+i*3 + 0] =   data[j*(width*3+nAdjust24) + (width*3+nAdjust24 - i*3 - 1)];
			data_T[j*(width*3+nAdjust24)+i*3 + 1] =   data[j*(width*3+nAdjust24)+ (width*3+nAdjust24 - i*3 - 1 - 1)];
			data_T[j*(width*3+nAdjust24)+i*3 + 2]  =  data[j*(width*3+nAdjust24)+ (width*3+nAdjust24 - i*3 - 2 - 1)];
		}
	}

	RESULT s = {0,0,data_T};
	s = Bmp_Cut2(data_T,width,height);

	/***********************************/
	_BITMAPINFOHEADER bih = {0,0,0,0,0,0,0,0,0,0,0};		// bmp头信息
	int nAdjust; // 用于字节对齐
	/*****************************/
	bih.biSize = 40;
	bih.biWidth = s.width;
	bih.biHeight = s.height;
	bih.biPlanes = 1;
	bih.biBitCount = 24;
	bih.biCompression = BI_RGB;
	bih.biSizeImage = ((bih.biWidth%4 == 0 ) ? bih.biWidth : (bih.biWidth + bih.biWidth % 4) ) * bih.biHeight;
	bih.biXPelsPerMeter = 300;
	bih.biYPelsPerMeter = 300;
	bih.biClrUsed = 0;
	bih.biClrImportant = 0;

	nAdjust = bih.biWidth%4;
	if (nAdjust) nAdjust = 4-nAdjust;
	// 24位字节对齐
	nAdjust24 = bih.biWidth*3%4;
	if (nAdjust24) nAdjust24 = 4-nAdjust24;
	/****************************/

	//对位图信息封装
	BMPINFOMATION bmp;

	bmp.bih = bih;
	bmp.nComponent = 3;
	bmp.data = s.data;
	bmp.pData24 = s.data;
	bmp.nAdjust24 = nAdjust24;
	bmp.nAdjust = nAdjust;
	// 以上图像读取完毕
	saveAsBmp(bmp,out);
	/*********************************/

}