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


C++ Contour::Extent方法代码示例

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


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

示例1: MakeContourBitmap

HBITMAP MakeContourBitmap( HWND hWnd, Contour *contour )	// Convert pixel offset contour into a bitmap for button
{
    Contour *c;
    Point *p, min, max;
    double fx, fy, size;
    int i, numpts;
    POINT *lpPoints;
    HPEN pen;
    HBRUSH brush;
    HBITMAP canvas, stipple;
    RECT wrect;
    HDC winDC, canvasDC;

    winDC = GetDC( hWnd );							// create bitmap for contour image					
    canvas = CreateCompatibleBitmap( winDC, ButtonSize, ButtonSize );
    canvasDC = CreateCompatibleDC( winDC );			// create DC for drawing
    SelectObject( canvasDC, canvas );				// select bitmap in DC for drawing
    ReleaseDC( hWnd, winDC );						// done with display DC for now

    GetClientRect( hWnd, &wrect );					// paint background
    stipple = LoadBitmap(appInstance, "StippleBitmap");
    brush = CreatePatternBrush( stipple );
    FillRect( canvasDC, &wrect, brush );
    DeleteObject( brush );
    DeleteObject( stipple );
    
    c = new Contour( *contour );
    c->YInvert( 0.0 );								// flip y coord. offsets
    c->Extent( &min, &max );						// how big is it?
    fx = max.x - min.x;
    fy = max.y - min.y;								// if it's bigger than the bitmap
    if ( fy > fx ) fx = fy;							// squeeze it down into bitmap size
    size = ButtonSize - 4;
    if ( fx > size ) c->Scale( (double)size/(double)fx );
    c->Shift( ButtonSize/2, ButtonSize/2 );	// center on bitmap

    numpts = c->points->Number();
    lpPoints = new POINT[ numpts ];					// create Window POINT array for drawing
    i = 0;
    p = c->points->first;							// translate shrunken contour into POINTS
    while ( p != NULL )
        {
        lpPoints[i].x = (int)floor(p->x);
        lpPoints[i].y = (int)floor(p->y);
        i++;
        p = p->next;
        }
                                                    // create pen for border of object
    pen = CreatePen( PS_SOLID, 1, c->border.ref() );
    SelectObject( canvasDC, pen );					// set pen into device context
    brush = CreateSolidBrush( c->fill.ref() );		// interior will be filled
    SelectObject( canvasDC, brush );
    SetROP2( canvasDC, abs(c->mode) );				// using contour fill mode and color
    Polygon( canvasDC, lpPoints, numpts );

    SelectObject( canvasDC, (HBRUSH)GetStockObject(NULL_BRUSH) );
    DeleteObject(brush);							// clean up fill brush

    SetROP2( canvasDC, R2_COPYPEN );				// draw contour border with pen only
    Polygon( canvasDC, lpPoints, numpts );

    DeleteObject(pen);								// clean up pen
    delete[] lpPoints;								// and dynamic memory
    DeleteDC( canvasDC );

    return( canvas );
}
开发者ID:meawoppl,项目名称:reconstruct-1101,代码行数:67,代码来源:palette.cpp


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