当前位置: 首页>>代码示例>>C++>>正文


C++ BitMap::GetWidth方法代码示例

本文整理汇总了C++中BitMap::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BitMap::GetWidth方法的具体用法?C++ BitMap::GetWidth怎么用?C++ BitMap::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitMap的用法示例。


在下文中一共展示了BitMap::GetWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, const char * argv[])
{
	/* This code tests your bitmap implementation on 24-bit and 32-bit files. The desired output
	 * files are included for comparison purposes.
	 */
	
	
	/** Test #1: Create a new file with a gradient from yellow to green to cyan (bottom to top) */
	//parameterized  constructor
	BitMap *bm = new BitMap(255, 255);
	//bm->Load("picture.bmp");

	for (int x = 0; x < 255; x++)
	{
		for (int y = 0; y < 255; y++)
		{
			//std::cout << "x: " << x << "y: " << y << std::endl;
			bm->SetPixel(bm, x, y, 255-y, 255, y, 255);
		}
	}
	
	/** copy constructor*/
	BitMap *a = new BitMap(*bm);
	/** assignment Operator*/
	*a = *a;
	std::cout << "Get Height function: " << a->GetHeight() << "\n";
	std::cout << "Get Width function: " << a->GetWidth() << "\n";
	/** Destructor*/
	bm->~BitMap();

	/*std::cout << "processing test.bmp\n";
	bm->Save(bm, "test.bmp");*/
	///* test #2: a 24-bit file with reversed height; add a 40x40 red square in the lower right corner */
	//std::cout << "processing picture.bmp\n";
	//bm = bm->Load("picture.bmp");
	//if (bm == 0)
	//{
	//	std::cout << "load of 'picture.bmp' failed\n";
	//}
	//else {
	//	for (int x = 0; x < 40; x++)
	//	{
	//		for (int y = 0; y < 40; y++)
	//		{
	//			bm->SetPixel(bm, (bm->GetWidth())-x-1, y, 255, 0, 0, 255);
	//		}
	//	}
	//	bm->Save(bm, "picture new.bmp");
	//	free(bm);
	//}

	///** test #3: a 24-bit file; add a 40x40 blue square in the upper right corner */
	//std::cout << "processing train.bmp\n";
	//bm = bm->Load("train.bmp");
	//if (bm == 0)
	//{
	//	std::cout << "load of 'train.bmp' failed\n";
	//}
	//else {
	//	for (int x = 0; x < 40; x++)
	//	{
	//		for (int y = 0; y < 40; y++)
	//		{
	//			bm->SetPixel(bm, bm->GetWidth()-x-1, bm->GetHeight()-y-1, 0, 0, 255, 255);
	//		}
	//	}
	//	bm->Save(bm, "train new.bmp");
	//	free(bm);
	//}

	///** test #4: a 24-bit file with padding; add a 40x40 blue square in the upper right corner */
	//std::cout << "processing mountain.bmp\n";
	//bm = bm->Load("mountain.bmp");
	//if (bm == 0)
	//{
	//	std::cout << "load of 'mountain.bmp' failed\n";
	//}
	//else {
	//	// convert to grayscale
	//	for (int x = 0; x < bm->GetWidth(); x++)
	//	{
	//		for (int y = 0; y < bm->GetHeight(); y++)
	//		{
	//			uint8_t r, g, b, a;
	//			bm->GetPixel(bm, x, y, r, g, b, a);
	//			uint8_t average = (r+g+b)/3;
	//			bm->SetPixel(bm, x, y, average, average, average, a);
	//		}
	//	}
	//	bm->Save(bm, "mountain new.bmp");
	//	free(bm);
	//}

	///** test #4: a 32-bit file with reversed height; extract the green channel */
	//std::cout << "processing canmore.bmp\n";
	//bm = bm->Load("canmore.bmp");
	//if (bm == 0)
	//{
	//	std::cout << "load of 'canmore.bmp' failed\n";
	//}
//.........这里部分代码省略.........
开发者ID:FalseShepherd,项目名称:System-Programming,代码行数:101,代码来源:main.cpp


注:本文中的BitMap::GetWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。