本文整理汇总了C++中Contour::YInvert方法的典型用法代码示例。如果您正苦于以下问题:C++ Contour::YInvert方法的具体用法?C++ Contour::YInvert怎么用?C++ Contour::YInvert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contour
的用法示例。
在下文中一共展示了Contour::YInvert方法的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 );
}