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


C++ CDib::CreateCDib方法代码示例

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


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

示例1: Translation

VOID CDibUtil::Translation(CDib& src, CDib& dest, CPoint& translation)
{
	CSize imageSize = src.GetDimensions();

	ASSERT(imageSize.cx + translation.x >= 0);
	ASSERT(imageSize.cy + translation.y >= 0);
	dest.CreateCDib(CSize(imageSize.cx + translation.x, imageSize.cy + translation.y),
		src.m_lpBMIH->biBitCount);

	for (LONG y = 0, dy = translation.y; y != imageSize.cy; ++y, dy = y + translation.y)
		for (LONG x = 0, dx = translation.x; x != imageSize.cx; ++x, dx = x + translation.x)
		{
			if (dy >= 0 && dx >= 0)
			{
				dest.WritePixel(dx, dy, src.GetPixel(x, y));
			}
		}
}
开发者ID:microdog,项目名称:DigitalImageProcessingCourseProject,代码行数:18,代码来源:DibUtil.cpp

示例2: Rotation

/*
 * See http://www.leunen.com/cbuilder/rotbmp.html
 */
VOID CDibUtil::Rotation(CDib& src, CDib& dest, DOUBLE angle)
{
	CSize imageSize = src.GetDimensions();
	LONG width = imageSize.cx;
	LONG height = imageSize.cy;

	// Convert angle to radians
	FLOAT radians = (FLOAT)(angle * M_PI / 180.0);
	FLOAT cosine = (FLOAT)cos(radians);
	FLOAT sine = (FLOAT)sin(radians);
	
	// Compute dimensions of the resulting bitmap
	// First get the coordinates of the 3 corners other than origin
	FLOAT x1 = (-height * sine);
	FLOAT y1 = ( height * cosine);
	FLOAT x2 = ( width  * cosine - height * sine);
	FLOAT y2 = ( height * cosine + width * sine);
	FLOAT x3 = ( width  * cosine);
	FLOAT y3 = ( width  * sine);
	
	FLOAT minx = min(0, min(x1, min(x2, x3)));
	FLOAT miny = min(0, min(y1, min(y2, y3)));
	FLOAT maxx = max(x1, max(x2, x3));
	FLOAT maxy = max(y1, max(y2, y3));
	
	LONG newWidth = (LONG)ceil(fabs(maxx) - minx);
	LONG newHeight = (LONG)ceil(fabs(maxy) - miny);

	dest.CreateCDib(CSize(newWidth, newHeight), src.m_lpBMIH->biBitCount);

	LONG sx, sy;
	for(LONG y = 0; y < newHeight; ++y )
		for(LONG x = 0; x < newWidth; ++x )
		{
			sx = (LONG)((x + minx) * cosine + (y + miny) * sine);
			sy = (LONG)((y + miny) * cosine - (x + minx) * sine);
			if( sx >= 0 && sx < width && sy >= 0 && sy < height )
				dest.WritePixel(x, y, src.GetPixel(sx, sy));
		}
}
开发者ID:microdog,项目名称:DigitalImageProcessingCourseProject,代码行数:43,代码来源:DibUtil.cpp


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