program_10_5.cpp

来自「清华关于C++ 的程序讲义 值得一看 关于算法」· C++ 代码 · 共 38 行

CPP
38
字号
// Display a bitmap image of the authors in the
// center of a window
#include <bitmap>
#include <cassert>
using namespace std;

SimpleWindow PhotoWindow("The Lecturer", 10., 12., Position(5., 3.));

// ApiMain(): display a bitmap photo
int ApiMain() {
	PhotoWindow.Open();
	assert(PhotoWindow.GetStatus() == WindowOpen);

	Position WindowCenter = PhotoWindow.GetCenter();

	// Create a bitmap
	BitMap Photo(PhotoWindow);

	// Load the image
	Photo.Load("me.bmp");
	assert(Photo.GetStatus() == BitMapOkay);

	//Compute photo position so it's center in the window
	// (photo's upper-left corner)
	Position PhotoPosition = WindowCenter + Position(-.5 * Photo.GetWidth(),
	                                  -.5 * Photo.GetHeight());
	Photo.SetPosition(PhotoPosition);
	Photo.Draw();

	return 0;
}

// ApiEnd(): shutdown the window
int ApiEnd() {
	PhotoWindow.Close();
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?