本文整理汇总了C++中Contour::Scale方法的典型用法代码示例。如果您正苦于以下问题:C++ Contour::Scale方法的具体用法?C++ Contour::Scale怎么用?C++ Contour::Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contour
的用法示例。
在下文中一共展示了Contour::Scale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawEditContour
void ViewPort::DrawEditContour( double pixel_size, double offset_x, double offset_y )
{
HPEN pen, oldpen;
HBRUSH brush, oldbrush;
LOGBRUSH lbrush;
int oldmode, i, x, y, numpts;
Contour *c;
Point *p;
POINT *lpPoints;
if ( EditContour && viewDC )
if ( EditContour->points )
{
c = new Contour( *EditContour ); // copy the contour
c->Shift( -offset_x, -offset_y ); // shift into view
c->Scale( 1.0/pixel_size ); // scale to view's pixels
numpts = c->points->Number();
lpPoints = new POINT[ numpts ]; // create Window POINT array for drawing
i = 0;
p = c->points->first;
while ( p != NULL )
{
lpPoints[i].x = (int)floor(p->x);
lpPoints[i].y = height - (int)floor(p->y);
i++;
p = p->next;
}
// create pen for border of object
pen = CreatePen( PS_DOT, 1, c->border.ref() );
//pen = CreatePen( PS_SOLID, 1, c->border.ref() );
oldpen = (HPEN)SelectObject( viewDC, pen ); // set pen into device context
if ( (c->mode > 0) && c->closed )
{
brush = CreateSolidBrush( c->fill.ref() ); // interior will be filled
oldbrush = (HBRUSH)SelectObject( viewDC, brush );
SetROP2( viewDC, abs(c->mode) ); // using contour fill mode and color
Polygon( viewDC, lpPoints, numpts );
SelectObject( viewDC, oldbrush ); // clean up fill brush
DeleteObject(brush);
}
SelectObject( viewDC, (HBRUSH)GetStockObject(NULL_BRUSH) ); // without coloring interior
SetROP2( viewDC, R2_COPYPEN ); // draw contour border with pen
if ( c->closed ) Polygon( viewDC, lpPoints, numpts );
else Polyline( viewDC, lpPoints, numpts );
SelectObject( viewDC, oldpen ); // clean up pen
DeleteObject(pen);
delete[] lpPoints; // and dynamic memory
delete c;
}
}
示例2: 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 );
}
示例3: RenderImages
void ViewPort::RenderImages( RECT region, double pixel_size, double offset_x, double offset_y, bool use_proxy )
{
Transform *transform; // render image onto view using pixel_size
Point *p, min, max;
Contour *domain;
RECT r, labeled;
double x, y, area;
int index, i;
char txt[128];
Image_Ptr images[MAX_DOMAINS]; // number of domains is limited by 8bit mask size
Nform_Ptr nforms[MAX_DOMAINS];
POINT mins[MAX_DOMAINS], maxs[MAX_DOMAINS];
// begin debug logging...
DWORD byteswritten;
char line[MAX_PATH];
if ( debugLogFile != INVALID_HANDLE_VALUE )
{
sprintf(line,"Entered ViewPort::RenderImages\r\n");
WriteFile(debugLogFile, line, strlen(line), &byteswritten, NULL);
}
// ...end debug logging
startTime3 = GetTickCount();
// check for valid render region
if ( (region.right - region.left) < 0 ) return;
if ( (region.bottom - region.top) < 0 ) return;
// limit render region to view pixels
if ( region.left < 0 ) r.left = 0; else r.left = region.left;
if ( region.right >= width ) r.right = width-1; else r.right = region.right;
if ( region.top < 0 ) r.top = 0; else r.top = region.top;
if ( region.bottom >= height ) r.bottom = height-1; else r.bottom = region.bottom;
ClearImages( r ); // clear the region to all zeros before rendering
for (index=0; index < MAX_DOMAINS; index++) // clear the image and nform pointer arrays
{
images[index] = NULL;
nforms[index] = NULL;
}
if ( section->transforms )
{ // FIRST PASS... Create index mask for images on view
index = 0; // count every domain in section with index
transform = section->transforms->first; // render in order, back to front
while ( transform && (index < MAX_DOMAINS) )
{
if ( transform->image ) // do only if image is present and not hidden
{
if ( transform->domain && !transform->domain->hidden )
{ // use domain boundary to define render area...
index++;
domain = new Contour( *(transform->domain) ); // create a copy of domain
domain->Scale( transform->image->mag ); // go from pixels to units
domain->InvNform( transform->nform ); // transform into section
domain->Shift( -offset_x, -offset_y ); // shift from view offset
labeled = view->Mask( domain, pixel_size, index, r ); // label pixels for rendering
if ( labeled.left <= labeled.right ) // only use if some interior pixels were set
{
images[index] = transform->image; // store ptr to image for later rendering step
nforms[index] = transform->nform;
mins[index].x = labeled.left; mins[index].y = labeled.top;
maxs[index].x = labeled.right; maxs[index].y = labeled.bottom;
}
delete domain; // delete copy of domain
}
}
transform = transform->next; // do next transform in list
}
while ( index > 0 ) // SECOND PASS... render each indexed subregion from image sources
{
view->MaskXform( images[index], nforms[index], index, mins[index], maxs[index],
pixel_size, offset_x, offset_y, use_proxy );
index--;
}
}
totalTime3 += GetTickCount() - startTime3; // DEBUGGING
nTime3++;
}
示例4: Init
//.........这里部分代码省略.........
contour->points->Add(p);
}
contour = new Contour();
PointContours->Add( contour );
sprintf(contour->name,"X$+");
contour->mode = -R2_COPYPEN;
contour->simplified = true;
contour->border = Color( 1.0, 0.0, 0.0 ); // red
contour->fill = Color( 1.0, 0.0, 0.0 );
contour->points = new Points(); // x shape
int x[] = { -7, 7, -2, 0, -7, -7, -4, -7, 0, -1, 4, -7, 7, -7, 2, 0, 7, 7, 4, 7, 0, 1, -4, 7 };
for ( i=0; i<24; i=i+2 )
{
p = new Point((double)x[i],(double)x[i+1],0.0);
contour->points->Add(p);
}
contour = new Contour();
PointContours->Add( contour );
sprintf(contour->name,"yellow$+"); // yellow
contour->mode = -R2_COPYPEN;
contour->simplified = true;
contour->border = Color( 1.0, 1.0, 0.0 );
contour->fill = Color( 1.0, 1.0, 0.0 );
contour->points = new Points(); // square annulus shape
int square[] = { -4, 4, -5, 5, 5, 5, 5, -5, -5, -5, -5, 4, -4, 3, -4, -4, 4, -4, 4, 4 };
for ( i=0; i<20; i=i+2 )
{
p = new Point((double)square[i],(double)square[i+1],0.0);
contour->points->Add(p);
}
contour->Reverse(); // make for clockwise creation
contour->Scale( 2.0 ); // double in size
contour = new Contour();
PointContours->Add( contour );
sprintf(contour->name,"blue$+"); // blue
contour->mode = R2_MASKPEN;
contour->simplified = true;
contour->border = Color( 0.0, 0.0, 1.0 );
contour->fill = Color( 0.0, 0.0, 1.0 );
contour->points = new Points(); // diamond shape
int diamond[] = { 0, 7, -7, 0, 0, -7, 7, 0 };
for ( i=0; i<8; i=i+2 )
{
p = new Point((double)diamond[i],(double)diamond[i+1],0.0);
contour->points->Add(p);
}
contour = new Contour();
PointContours->Add( contour );
sprintf(contour->name,"magenta$+");
contour->mode = R2_MASKPEN;
contour->simplified = true;
contour->border = Color( 1.0, 0.0, 1.0 ); // magenta
contour->fill = Color( 1.0, 0.0, 1.0 );
contour->points = new Points(); // larger hexagonal shape
for ( i=0; i<16; i=i+2 )
{
p = new Point((double)hexagon[i],(double)hexagon[i+1],0.0);
contour->points->Add(p);
}
contour->Scale( 2.0 ); // double in size
contour = new Contour();